/** * Create a new awimage */ function create() { if ($this->resource === NULL) { // Create image $this->resource = imagecreatetruecolor($this->width, $this->height); if (!$this->resource) { trigger_error("Unable to create a graph", E_USER_ERROR); } imagealphablending($this->resource, TRUE); if ($this->antiAliasing and function_exists('imageantialias')) { imageantialias($this->resource, TRUE); } $this->drawer = new awDrawer($this->resource); $this->drawer->setImageSize($this->width, $this->height); // Original color $this->drawer->filledRectangle(new awWhite(), new awLine(new awPoint(0, 0), new awPoint($this->width, $this->height))); $shadow = $this->shadow->getSpace(); $p1 = new awPoint($shadow->left, $shadow->top); $p2 = new awPoint($this->width - $shadow->right - 1, $this->height - $shadow->bottom - 1); // Draw image background $this->drawer->filledRectangle($this->background, new awLine($p1, $p2)); $this->background->free(); // Draw image border $this->border->rectangle($this->drawer, $p1, $p2); } }
function ajaxRequest() { $view = $this->tpl(); $view->assign('empty', $this->prepareSearch('')); Drawer::fill($view->draw('_search', true), true); RPC::call('Search.init'); }
function ajaxCreate($server, $node, $id = false, $reply = false) { if (!$this->validateServerNode($server, $node)) { return; } $post = false; $view = $this->tpl(); if ($id) { $pd = new \modl\PostnDAO(); $p = $pd->get($server, $node, $id); if ($p->isEditable() && !$reply) { $post = $p; } if ($p->isReply()) { $reply = $p->getReply(); } elseif ($reply) { $reply = $p; } } if ($reply) { $view->assign('to', $this->user->getLogin()); $view->assign('node', 'urn:xmpp:microblog:0'); $view->assign('item', $post); $view->assign('reply', $reply); } else { $view->assign('to', $server); $view->assign('node', $node); $view->assign('item', $post); $view->assign('reply', false); } if ($node == 'urn:xmpp:microblog:0') { RPC::call('MovimUtils.pushState', $this->route('news')); } else { RPC::call('MovimUtils.removeClass', '#group_widget', 'fixed'); } if ($reply) { Drawer::fill('<section>' . $view->draw('_publish_create', true) . '</section>'); } else { RPC::call('MovimTpl.fill', 'main section > div:nth-child(2)', $view->draw('_publish_create', true)); } $pd = new \Modl\ItemDAO(); $item = $pd->getItem($server, $node); $view = $this->tpl(); $view->assign('server', $server); $view->assign('node', $node); $view->assign('post', $post); $view->assign('item', $item); //Header::fill($view->draw('_publish_header', true)); if ($id) { RPC::call('Publish.initEdit'); } RPC::call('Publish.setEmbed'); }
function ajaxGetDrawer($jid) { if (!$this->validateJid($jid)) { return; } $tpl = $this->tpl(); $cd = new \Modl\ContactDAO(); $cr = $cd->getRosterItem($jid); if (isset($cr)) { if ($cr->value != null) { $tpl->assign('presence', getPresencesTxt()[$cr->value]); } $tpl->assign('contactr', $cr); $tpl->assign('caps', $cr->getCaps()); $tpl->assign('clienttype', getClientTypes()); } $c = $cd->get($jid); $tpl->assign('contact', $c); Drawer::fill($tpl->draw('_contact_drawer', true)); }
function polygonLinearGradient(&$gradient, &$polygon) { $count = $polygon->count(); if($count >= 3) { $left = $polygon->get(0); $right = $polygon->get($count - 1); if($gradient->angle === 0) { // Get polygon maximum and minimum $offset = $polygon->get(0); $max = $min = $offset->y; for($i = 1; $i < $count - 1; $i++) { $offset = $polygon->get($i); $max = max($max, $offset->y); $min = min($min, $offset->y); } $this->init($gradient, $max - $min); $prev = $polygon->get(1); $sum = 0; for($i = 2; $i < $count - 1; $i++) { $current = $polygon->get($i); $interval = 1; if($i !== $count - 2) { $current->x -= $interval; } if($current->x - $prev->x > 0) { // Draw rectangle $x1 = $prev->x; $x2 = $current->x; $y1 = max($prev->y, $current->y); $y2 = $left->y; $gradient = new awLinearGradient( $this->color($max - $min - ($y2 - $y1)), $this->color($max - $min), 0 ); if($y1 > $y2) { $y2 = $y1; } $this->drawer->filledRectangle( $gradient, awLine::build($x1, $y1, $x2, $y2) ); $top = ($prev->y < $current->y) ? $current : $prev; $bottom = ($prev->y >= $current->y) ? $current : $prev; $gradient = new awLinearGradient( $this->color($bottom->y - $min), $this->color($max - $min - ($y2 - $y1)), 0 ); $gradientDrawer = new awGradientDrawer($this->drawer); $gradientDrawer->drawFilledFlatTriangle( $gradient, new awPoint($prev->x, min($prev->y, $current->y)), $top, new awPoint($current->x, min($prev->y, $current->y)) ); unset($gradientDrawer); $sum += $current->x - $prev->x; } $prev = $current; $prev->x += $interval; } } else if($gradient->angle === 90) { $width = $right->x - $left->x; $this->init($gradient, $width); $pos = 1; $next = $polygon->get($pos++); $this->next($polygon, $pos, $prev, $next); for($i = 0; $i <= $width; $i++) { $x = $left->x + $i; $y1 = round($prev->y + ($next->y - $prev->y) * (($i + $left->x - $prev->x) / ($next->x - $prev->x))); $y2 = $left->y; // Draw line $color = $this->color($i); // YaPB : PHP does not handle alpha on lines $this->drawer->filledRectangle($color, awLine::build($x, $y1, $x, $y2)); $color->free(); unset($color); // Jump to next point if($next->x == $i + $left->x) { $this->next($polygon, $pos, $prev, $next); } } } } }
/** * @brief Show the smiley list */ function ajaxSmileyTwo($to) { if (!$this->validateJid($to)) { return; } $view = $this->tpl(); $view->assign('jid', $to); $view->assign('packs', $this->getPacks()); $view->assign('path', $this->respath('stickers')); Drawer::fill($view->draw('_stickers_smiley_two', true)); }
protected function drawImage(awPoint $point) { if ($this->image instanceof awImage) { $width = $this->image->width; $height = $this->image->height; list($x, $y) = $point->getLocation(); $x1 = (int) ($x - $width / 2); $x2 = $x1 + $width; $y1 = (int) ($y - $width / 2); $y2 = $y1 + $height; $this->border->rectangle($this->drawer, new awPoint($x1 - 1, $y1 - 1), new awPoint($x2 + 1, $y2 + 1)); $this->drawer->copyImage($this->image, new awPoint($x1, $y1), new awPoint($x2, $y2)); } }
<?php include_once '../../class/example/polymorphism.php'; // 沒用到繼承,只是很單純使用別的類別方法來處理事情,不是多型 /* $shape = new Shape(); $circle = new Circle(); $rectangle = new Rectangle(); $shape->draw($circle); $shape->draw($rectangle); */ /* $circle = new Circle(); $rectangle = new Rectangle(); */ // $shape = new Shape(); $circle = new Circle(); $rectangle = new Rectangle(); $drawer = new Drawer(); $drawer->addShape($circle); $drawer->addShape($rectangle); $drawer->drawAllShapes(); // $shapInterface = new ShapeInterface();