扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:Jack Herrington 来源:ibm 2007年10月21日
关键字: Linux
class GraphicsEnvironment { public $vsx; public $vsy; public $vex; public $vey; public $width; public $height; public $gdo; public $colors = array(); public function __construct( $width, $height, $vsx, $vsy, $vex, $vey ) { $this->vsx = $vsx; $this->vsy = $vsy; $this->vex = $vex; $this->vey = $vey; $this->width = $width; $this->height = $height; $this->gdo = imagecreatetruecolor( $width, $height ); $this->addColor( "white", 255, 255, 255 ); imagefilledrectangle( $this->gdo, 0, 0, $width, $height, $this->getColor( "white" ) ); } public function width() { return $this->width; } public function height() { return $this->height; } public function addColor( $name, $r, $g, $b ) { $this->colors[ $name ] = imagecolorallocate( $this->gdo, $r, $g, $b ); } public function getGraphicObject() { return $this->gdo; } public function getColor( $name ) { return $this->colors[ $name ]; } public function saveAsPng( $filename ) { imagepng( $this->gdo, $filename ); } public function tx( $x ) { $r = $this->width / ( $this->vex - $this->vsx ); return ( $x - $this->vsx ) * $r; } public function ty( $y ) { $r = $this->height / ( $this->vey - $this->vsy ); return ( $y - $this->vsy ) * $r; } } |
<?php require_once( "glib.php" ); $ge = new GraphicsEnvironment( 400, 400, -1000, -1000, 1000, 1000 ); $ge->addColor( "black", 0, 0, 0 ); $ge->addColor( "red", 255, 0, 0 ); $ge->addColor( "green", 0, 255, 0 ); $ge->addColor( "blue", 0, 0, 255 ); $g1 = new Group( 0 ); $g1->add( new Oval( 200, "red", -800, -800, 0, 0 ) ); $g1->add( new Rectangle( 100, "black", -400, -400, 900, 900 ) ); $g1->render( $ge ); $ge->saveAsPng( "test.png" ); ?> |
$ge = new GraphicsEnvironment( 400, 200, -1000, -1000, 1000, 1000 ); |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者