本文整理汇总了PHP中Shape类的典型用法代码示例。如果您正苦于以下问题:PHP Shape类的具体用法?PHP Shape怎么用?PHP Shape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Shape类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_getFullDescription
public function test_getFullDescription()
{
$shape = new Shape(4, 5);
$id = $shape->getId();
$name = str_shuffle(time());
$shape->name = $name;
$this->assertEquals('Shape<#' . $id . '>: ' . $name . ' - 4 x 5', $shape->getFullDescription());
}
开发者ID:CodeLouisville,项目名称:php-exercise-oop,代码行数:8,代码来源:ShapeTest.php
示例2: __construct
public function __construct($x, $y, $radius, $drawAPI)
{
Shape::__construct($drawAPI);
$this->x = $x;
$this->y = $y;
$this->radius = $radius;
}
开发者ID:possientis,项目名称:Prog,代码行数:7,代码来源:bridge.php
示例3: __construct
public function __construct($id, $width, $height)
{
Shape::setID($id);
$this->setHeight($height);
$this->setWidth($width);
$this->setArea();
}
开发者ID:lctstitchlabstest,项目名称:FtL,代码行数:7,代码来源:Rectangle.php
示例4: getKey
/**
* @return Shape
*/
public function getKey()
{
if (!$this->key) {
$this->key = isset($this->definition['key']) ? Shape::create($this->definition['key'], $this->shapeMap) : new Shape(['type' => 'string'], $this->shapeMap);
}
return $this->key;
}
开发者ID:abdala,项目名称:generic-api-client,代码行数:10,代码来源:MapShape.php
示例5: CircleShape
public function CircleShape($x, $y, $radius, DrawingAPI $drawingAPI)
{
parent::Shape($drawingAPI);
$this->x = $x;
$this->y = $y;
$this->radius = $radius;
}
开发者ID:manachyn,项目名称:trainings,代码行数:7,代码来源:BridgeWiki_en.php
示例6: __construct
public function __construct(array $definition, ShapeMap $shapeMap)
{
$definition['type'] = 'structure';
if (!isset($definition['members'])) {
$definition['members'] = [];
}
parent::__construct($definition, $shapeMap);
}
开发者ID:ossistyle,项目名称:http-client-description,代码行数:8,代码来源:StructureShape.php
示例7: getMember
/**
* @return Shape
*
* @throws \RuntimeException if no member is specified
*/
public function getMember()
{
if (!$this->member) {
if (!isset($this->definition['member'])) {
throw new \RuntimeException('No member attribute specified');
}
$this->member = Shape::create($this->definition['member'], $this->shapeMap);
}
return $this->member;
}
开发者ID:ossistyle,项目名称:http-client-description,代码行数:15,代码来源:ListShape.php
示例8: resolve
/**
* Resolve a shape reference
*
* @param array $shapeRef Shape reference shape
*
* @return Shape
* @throws \InvalidArgumentException
*/
public function resolve(array $shapeRef)
{
$shape = $shapeRef['shape'];
if (!isset($this->definitions[$shape])) {
throw new \InvalidArgumentException('Shape not found: ' . $shape);
}
$isSimple = count($shapeRef) == 1;
if ($isSimple && isset($this->simple[$shape])) {
return $this->simple[$shape];
}
$definition = $shapeRef + $this->definitions[$shape];
$definition['name'] = $definition['shape'];
unset($definition['shape']);
$result = Shape::create($definition, $this);
if ($isSimple) {
$this->simple[$shape] = $result;
}
return $result;
}
开发者ID:Air-Craft,项目名称:air-craft-www,代码行数:27,代码来源:ShapeMap.php
示例9: testResize
/**
* @dataProvider providerResize
* @param Shape $shape
* @param float $factor
*/
public function testResize(Shape $shape, $factor)
{
$expectedPerimeter = round($shape->getPerimeter() * $factor, 2);
$shape->scale($factor);
$this->assertEquals($expectedPerimeter, round($shape->getPerimeter(), 2));
}
开发者ID:arogulin,项目名称:shapes,代码行数:11,代码来源:ShapesTest.php
示例10: __construct
public function __construct(array $definition, ShapeMap $shapeMap)
{
$definition['type'] = 'timestamp';
parent::__construct($definition, $shapeMap);
}
开发者ID:Air-Craft,项目名称:air-craft-www,代码行数:5,代码来源:TimestampShape.php
示例11:
<?php
/**
* Copyright (c) 2014 Keith Casey.
*
* This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
* by Keith Casey. If you've received this code without seeing the videos, go watch the
* videos. It will make way more sense and be more useful in general.
*/
include_once 'shapes.php';
$shape = Shape::getShape('circle', 3);
// This should output 9*Pi
echo $shape->getArea();
$shape = Shape::getShape('square', 3);
// This should output 9
echo $shape->getArea();
开发者ID:matteo-hertel,项目名称:archive,代码行数:16,代码来源:index.php
示例12: Circle
# This file illustrates the low-level C++ interface
# created by SWIG. In this case, all of our C++ classes
# get converted into function calls.
require "example.php";
# ----- Object creation -----
print "Creating some objects:\n";
$c = new Circle(10);
print " Created circle \$c\n";
$s = new Square(10);
print " Created square \$s\n";
# ----- Create the ShapeContainer ----
$container = new ShapeContainer();
$container->addShape($c);
$container->addShape($s);
# ----- Access a static member -----
print "\nA total of " . Shape::nshapes() . " shapes were created\n";
# ----- Delete by the old references -----
# This should not truely delete the shapes because they are now owned
# by the ShapeContainer.
print "Delete the old references.";
# Note: this invokes the virtual destructor
$c = NULL;
$s = NULL;
print "\nA total of " . Shape::nshapes() . " shapes remain\n";
# ----- Delete by the container -----
# This should truely delete the shapes
print "Delete the container.";
$container = NULL;
print "\nA total of " . Shape::nshapes() . " shapes remain\n";
print "Goodbye\n";
开发者ID:msornay,项目名称:swig,代码行数:30,代码来源:runme.php
示例13: Circle
$c = new Circle(10);
print " Created circle \$c\n";
$s = new Square(10);
print " Created square \$s\n";
# ----- Access a static member -----
print "\nA total of " . Shape::nshapes() . " shapes were created\n";
# ----- Member data access -----
# Set the location of the object.
# Note: methods in the base class Shape are used since
# x and y are defined there.
$c->x = 20;
$c->y = 30;
$s->x = -10;
$s->y = 5;
print "\nHere is their current position:\n";
print " Circle = (" . $c->x . "," . $c->y . ")\n";
print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
print "\nCall some overloaded methods:\n";
foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
print " overloaded = " . overloaded($o) . "\n";
}
# Need to unset($o) or else we hang on to a reference to the Square object.
unset($o);
# ----- Delete everything -----
print "\nGuess I'll clean up now\n";
# Note: this invokes the virtual destructor
unset($c);
$s = 42;
print Shape::nshapes() . " shapes remain\n";
print "Goodbye\n";
开发者ID:daxiazh,项目名称:swig,代码行数:31,代码来源:runme.php
示例14: CanvasGraph
// $Id$
include "../jpgraph.php";
include "../jpgraph_canvas.php";
include "../jpgraph_canvtools.php";
// Define work space
$xmax = 40;
$ymax = 40;
// Setup a basic canvas we can work
$g = new CanvasGraph(400, 200, 'auto');
$g->SetMargin(5, 11, 6, 11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Create a new scale
$scale = new CanvasScale($g);
$scale->Set(0, $xmax, 0, $ymax);
// The shape class is wrapper around the Imgae class which translates
// the coordinates for us
$shape = new Shape($g, $scale);
$shape->SetColor('black');
$shape->IndentedRectangle(1, 2, 15, 15, 8, 8, CORNER_TOPLEFT, 'khaki');
$shape->IndentedRectangle(1, 20, 15, 15, 8, 8, CORNER_BOTTOMLEFT, 'khaki');
$shape->IndentedRectangle(20, 2, 15, 15, 8, 8, CORNER_TOPRIGHT, 'khaki');
$shape->IndentedRectangle(20, 20, 15, 15, 8, 8, CORNER_BOTTOMRIGHT, 'khaki');
// Stroke the graph
$g->Stroke();
?>
开发者ID:Artea,项目名称:freebeer,代码行数:29,代码来源:canvasex06.php
示例15: foreach
# Set the location of the object.
# Note: methods in the base class Shape are used since
# x and y are defined there.
$c->x = 20;
$c->y = 30;
$s->x = -10;
$s->y = 5;
print "\nHere is their current position:\n";
print " Circle = (" . $c->x . "," . $c->y . ")\n";
print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
print "\nHere are some properties of the shapes:\n";
foreach (array($c, $s) as $o) {
print " " . get_class($o) . " \$o\n";
print " x = " . $o->x . "\n";
print " y = " . $o->y . "\n";
print " area = " . $o->area() . "\n";
print " perimeter = " . $o->perimeter() . "\n";
}
# Need to unset($o) or else we hang on to a reference to the Square object.
unset($o);
# ----- Delete everything -----
print "\nGuess I'll clean up now\n";
# Note: this invokes the virtual destructor
unset($c);
$s = 42;
print Shape::nshapes() . " shapes remain\n";
print "Manually setting nshapes\n";
Shape::nshapes(42);
print Shape::get_nshapes() . " == 42\n";
print "Goodbye\n";
开发者ID:daxiazh,项目名称:swig,代码行数:31,代码来源:runme.php
示例16: CanvasGraph
<?php
// $Id: canvasbezierex1.php,v 1.1.1.1 2005/11/30 23:01:53 gth2 Exp $
include "../jpgraph.php";
include "../jpgraph_canvas.php";
include "../jpgraph_canvtools.php";
// Setup canvas graph
$g = new CanvasGraph(400, 300);
$scale = new CanvasScale($g);
$shape = new Shape($g, $scale);
$g->title->Set('Bezier line with control points');
// Setup control point for bezier
$p = array(3, 6, 6, 9, 5, 3, 7, 4);
// Visualize control points
$shape->SetColor('blue');
$shape->Line($p[0], $p[1], $p[2], $p[3]);
$shape->FilledCircle($p[2], $p[3], -6);
$shape->SetColor('red');
$shape->Line($p[4], $p[5], $p[6], $p[7]);
$shape->FilledCircle($p[4], $p[5], -6);
// Draw bezier
$shape->SetColor('black');
$shape->Bezier($p);
// Frame it with a square
$shape->SetColor('navy');
$shape->Rectangle(0.5, 2, 9.5, 9.5);
// ... and stroke it
$g->Stroke();
?>
开发者ID:nourchene-benslimane,项目名称:rth_backup,代码行数:29,代码来源:canvasbezierex1.php
示例17: CanvasGraph
include "../jpgraph.php";
include "../jpgraph_canvas.php";
include "../jpgraph_canvtools.php";
// Scale we are using
$ymax = 24;
$xmax = 20;
// Setup the basic canvas
$g = new CanvasGraph(700, 650, 'auto');
$g->SetMargin(2, 3, 2, 3);
$g->SetMarginColor("teal");
$g->InitFrame();
// ... and a scale
$scale = new CanvasScale($g);
$scale->Set(0, $xmax, 0, $ymax);
// ... we need shape since we want the indented rectangle
$shape = new Shape($g, $scale);
$shape->SetColor('black');
// ... basic parameters for the overall image
$l = 2;
// Left margin
$r = 18;
// Row number to start the lowest line on
$width = 16;
// Total width
// Setup the two basic rectangle text object we will use
$tt = new CanvasRectangleText();
$tt->SetFont(FF_ARIAL, FS_NORMAL, 14);
$tt->SetFillColor('');
$tt->SetColor('');
$tt->SetFontColor('navy');
$t = new CanvasRectangleText();
开发者ID:nourchene-benslimane,项目名称:rth_backup,代码行数:31,代码来源:canvas_jpgarchex.php
示例18: CanvasGraph
$xmax = 20;
$ymax = 20;
// Setup a basic canvas we can work
$g = new CanvasGraph(400, 200, 'auto');
$g->SetMargin(5, 11, 6, 11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Create a new scale
$scale = new CanvasScale($g);
$scale->Set(0, $xmax, 0, $ymax);
// The shape class is wrapper around the Imgae class which translates
// the coordinates for us
$shape = new Shape($g, $scale);
$shape->SetColor('black');
// Add a black line
$shape->SetColor('black');
$shape->Line(0, 0, 20, 20);
// .. and a circle (x,y,diameter)
$shape->Circle(5, 14, 2);
// .. and a filled circle (x,y,diameter)
$shape->SetColor('red');
$shape->FilledCircle(11, 8, 3);
// .. add a rectangle
$shape->SetColor('green');
$shape->FilledRectangle(15, 8, 19, 14);
// .. add a filled rounded rectangle
$shape->SetColor('green');
$shape->FilledRoundedRectangle(2, 3, 8, 6);
开发者ID:hcvcastro,项目名称:pxp,代码行数:31,代码来源:canvasex03.php
示例19: test_getTypeDescription
public function test_getTypeDescription()
{
$this->assertEquals('Type: 1', Shape::getTypeDescription());
}
开发者ID:jwelmore82,项目名称:php-exercise-oop,代码行数:4,代码来源:ShapeTest.php
示例20: __construct
public function __construct($x, $y, $radius, IDrawer $drawer)
{
parent::__construct($drawer);
$this->x = $x;
$this->y = $y;
$this->radius = $radius;
}
开发者ID:manachyn,项目名称:trainings,代码行数:7,代码来源:BridgeWiki.php
注:本文中的Shape类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论