public static function HexToRGBA($hex, $alpha){ $res = Color::HexToRGB($hex); if( $alpha > 1 ){ $alpha = $alpha / 100; } elseif( $alpha < 0 ){ $alpha = 0; } $res[0]['alpha'] = $alpha; $res[1] = "rgba(" . substr($res[1], 3, -1) . ", $alpha)"; return $res; }
<?php set_include_path('.:backbone:global:jquery'); require_once('Template.php'); require_once('Color.php'); require_once('Image.php'); require_once('RedirectBrowserException.php'); require_once('Session.php'); require_once('URL.php'); $tmpl = new Template(); $tmpl->passedvar = "This string was passed through the Template object to be rendered in the HTML file."; $tmpl->hex = Color::RGBToHex(60, 120, 60); $tmpl->alpha = Color::HexToRGBA($tmpl->hex, .5); $tmpl->rgb = Color::HexToRGB($tmpl->hex); $img = new Image(); $img->source = 'portrait.png'; $img->Write->Normal(20, 20, "A Self Portrait of Me", 5, "#000000", 1); $img->destination = 'portrait2.png'; $img->output(); $img->clean(); unset($img); //start a session and store a variable; setSession(0,'/'); // expires with browser session, the root is '/' setSessionVar('foo', 'bar'); //there's no retrieval function, so this is kind of stupid if( !isset($_SESSION['foo']) ){ throw new RedirectBrowserException("example.php"); }