htmltoolkit

W3schoolscomcsscsscolornamesasp if color0

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ienna'=>'#A0522D','skyblue'=>'#87CEEB','slategray' =>'#708090','springgreen'=>'#00FF7F','tan'=>'#D2B48C','thistle'=>'#D8BFD8','turquoise' =>'#40E0D0','violetred'=>'#D02090','white'=>'#FFFFFF','yellow'=>'#FFFF00'); //http://www.w3schools.com/css/css_colornames.asp if ( ($color{0} != '#') and ( strstr($color,'(') === false ) ) $color = $common_colors[strtolower($color)]; if ($color{0} == '#') //case of #nnnnnn or #nnn { $cor = strtoupper($color); if (strlen($cor) == 4) // Turn #RGB into #RRGGBB { $cor = "#" . $cor{1} . $cor{1} . $cor{2} . $cor{2} . $cor{3} . $cor{3}; } $R = substr($cor, 1, 2); $vermelho = hexdec($R); $V = substr($cor, 3, 2); $verde = hexdec($V); $B = substr($cor, 5, 2); $azul = hexdec($B); $color = array(); $color['R']=$vermelho; $color['G']=$verde; $color['B']=$azul; } else //case of RGB(r,g,b) { $color = str_replace("rgb(",'',$color); //remove rgb( $color = str_replace("RGB(",'',$color); //remove RGB( PHP < 5 does not have str_ireplace $color = str_replace(")",'',$color); //remove ) $cores = explode(",", $color); $color = array(); $color['R']=$cores[0]; $color['G']=$cores[1]; $color['B']=$cores[2]; } if (empty($color)) return array('R'=>255,'G'=>255,'B'=>255); else return $color; // array['R']['G']['B'] } function ConvertSize($size=5,$maxsize=0){ // Depends of maxsize value to make % work properly. Usually maxsize == pagewidth //Identify size (remember: we are using 'mm' units here) if ( stristr($size,'px') ) $size *= 0.2645; //pixels elseif ( stristr($size,'cm') ) $size *= 10; //centimeters elseif ( stristr($size,'mm') ) $size += 0; //millimeters elseif ( stristr($size,'in') ) $size *= 25.4; //inches elseif ( stristr($size,'pc') ) $size *= 38.1/9; //PostScript picas elseif ( stristr($size,'pt') ) $size *= 25.4/72; //72dpi elseif ( stristr($size,'%') ) { $size += 0; //make "90%" become simply "90" $size *= $maxsize/100; } else $size *= 0.2645; //nothing == px return $size;...
View Full Document

This note was uploaded on 08/14/2009 for the course ITP 204X taught by Professor Dent during the Spring '08 term at USC.

Ask a homework question - tutors are online