조회 수 507 추천 수 1 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form
라이선스 MIT
function hex2rgb($color)
{
    $color = str_replace('#', '', $color);
    $hex = strlen($color) == 3
        ? [$color[0].$color[0], $color[1].$color[1], $color[2].$color[2]]
        : [$color[0].$color[1], $color[2].$color[3], $color[4].$color[5]];

    list($r, $g, $b) = $hex;
    return sprintf(
        'rgb(%s, %s, %s)',
        hexdec($r), hexdec($g), hexdec($b)
    );
}

function rgb2hex($r, $g = null, $b = null)
{
    if(strpos($r, 'rgb') !== false || strpos($r, 'rgba') !== false)
    {
        if(preg_match_all('/\(([^\)]*)\)/', $r, $matches) && isset($matches[1][0]))
        {
            list($r, $g, $b) = explode(',', $matches[1][0]);
        }
        else
        {
            return false;
        }
    }

    $result = '';
    foreach([$r, $g, $b] as $c)
    {
        $hex = base_convert($c, 10, 16);
        $result .= ($c < 16) ? ('0'.$hex) : $hex;
    }

    return '#'.$result;
}



PHP 함수 모음 라이브러리를 만드려고 검색하는 도중 쓸만한 코드가 보여 업로드 합니다.

https://github.com/ngfw/Recipe 에 포함된 코드이며,  MIT 라이선스를 따릅니다.


  1. [1.8a] Bootstrap 'Panel' 위젯 스타일

    Date2017.08.09 Category자료 Bytitle: 은메달도다 Views602
    Read More
  2. RBGE - 이쁘고 깔끔한 에러페이지

    Date2017.08.08 Category자료 Bytitle: 열려라 맛스타의 자물쇠TVJ Views687
    Read More
  3. Koa에서 자동으로 라우팅 채워주기

    Date2020.01.22 Category코드 BySeia Views437
    Read More
  4. JavaScript에서 파이썬 문자열 처리 함수 중 하나 (바인딩)를 구현

    Date2020.01.20 Category코드 BySeia Views463
    Read More
  5. html 초보가 만든 자소서

    Date2018.04.21 Category코드 Bytitle: 대한민국 국기gimmepoint Views652
    Read More
  6. HEX를 RGB로, RGB를 HEX로 바꾸는 PHP 코드

    Date2018.05.05 Category코드 By네모 Views507
    Read More
  7. Hello, World!를 출력해보자

    Date2018.04.21 Category코드 By네모 Views568
    Read More
  8. Git 저장소에서 자동으로 받아 업데이트하는 쉘 스크립트

    Date2017.09.16 Category코드 ByNoYeah Views651
    Read More
  9. Gentelella 레이아웃에 사용가능한 가격 테이블 위젯입니다.

    Date2017.07.03 Category자료 ByNoYeah Views638
    Read More
  10. Gentelella

    Date2017.06.29 Category자료 ByNoYeah Views806
    Read More
  11. even_move - 감성적인 에러 페이지

    Date2017.08.08 Category자료 Bytitle: 열려라 맛스타의 자물쇠TVJ Views798
    Read More
  12. C언어 삼중자를 이용한 코드

    Date2018.07.22 Category코드 Bytitle: 황금 서버 (30일)humit Views410
    Read More
  13. CMD로 로컬 연결 고정 IP 설정하기

    Date2018.02.06 Category코드 Bytitle: 황금 서버 (30일)humit Views1038
    Read More
  14. Cmd 에서 서비스 시작 / 종료하기

    Date2018.02.18 Category코드 ByProjectSE Views644
    Read More
  15. c 이진트리 전,중,후위 알고리즘

    Date2018.04.24 Category코드 Bytitle: 대한민국 국기gimmepoint Views495
    Read More
  16. AWSCLI, in a single file (portable, linux)

    Date2021.04.10 Category코드 BySeia Views165
    Read More
  17. AdminLTE용 에디터 스타일

    Date2017.07.07 Category자료 Bytitle: 은메달도다 Views770
    Read More
  18. AdBlock 접근 방지 애드온 v0.1

    Date2017.10.05 Category자료 By네모 Views649
    Read More
Board Pagination Prev 1 2 3 4 Next
/ 4