db에서 입력해둔 16진수 값을 가져와서
가져온 색상보다 진하게 할려고 하는데 힘드네요..
예를 들어
원래 색상
바꿀 색상
방법을 알려 주시거나 참조할수 있게 해주시면
감사하겠습니다.
|
답변 3개
채택된 답변
+20 포인트
2019-06-18 (화) 05:29:40
참내.... 하다보니 별별걸 다 만들었었네요. 반쯤 만들다 만 함수입니다.
참고는 될겁니다. 살펴보세요.
//◆ 특정 색상을 흐리거나 진한 색을 만들어 주는 함수
Copy
function colors( $color, $seqSu, $cutSu=4, $dir = "FF" ){ // 용법 : FF -> 흐리게, 00 -> 진하게 :: $color를 $dir 방향으로 $cutSu 조각으로 잘라 $seqSu 번째 수
$color = str_replace( "#", "", $color ); $cutSu = ceil( abs( $cutSu ) ); $seqSu = ceil( abs( $seqSu ) );
if( $cutSu < $seqSu ) { $t = $cutSu; $cutSu = $seqSu; $seqSu = $t; }
if( $cutSu == 0 || $seqSu == 0 ) return "#$color";
if( $cutSu == $seqSu ) return ( $dir == "FF" ? "#ffffff" : "#000000" );
if(!function_exists('upcolor')) { function upcolor( $tx,$cut,$seq ) { return str_pad( dechex( hexdec($tx) + ceil( ( hexdec(ff) - hexdec($tx) ) / $cut * $seq ) ), 2,0,0 ); } }
if(!function_exists('dncolor')) { function dncolor( $tx,$cut,$seq ) { return str_pad( dechex( hexdec($tx) - ceil( hexdec($tx) / $cut * $seq ) ), 2,0,0 ); } }
$tx1 = substr( $color, 0, 2 ); $tx2 = substr( $color, 2, 2 ); $tx3 = substr( $color, 4, 2 );
if( $dir == "FF" ) { $ntx1 = upcolor( $tx1, $cutSu, $seqSu ); $ntx2 = upcolor( $tx2, $cutSu, $seqSu ); $ntx3 = upcolor( $tx3, $cutSu, $seqSu ); }
else { $ntx1 = dncolor( $tx1, $cutSu, $seqSu ); $ntx2 = dncolor( $tx2, $cutSu, $seqSu ); $ntx3 = dncolor( $tx3, $cutSu, $seqSu ); }
return "#".$ntx1.$ntx2.$ntx3;
}
2019-06-18 (화) 04:32:35
2019-06-18 (화) 03:47:31
투명도를 이용하심이 어떠신가요?
opacity : 0.9; filter: alpha(opacity=90); -moz-opacity:0.9; -khtml-opacity: 0.9;
답변을 작성하려면 로그인이 필요합니다.