/
DrawingRectangle.php
executable file
·57 lines (43 loc) · 2.08 KB
/
DrawingRectangle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace Aspose\Imaging\DrawingImages;
use com\aspose\imaging\imageoptions\BmpOptions as BmpOptions;
use com\aspose\imaging\sources\StreamSource as StreamSource;
use com\aspose\imaging\Image as Image;
use com\aspose\imaging\Color as Color;
use com\aspose\imaging\Pen as Pen;
use com\aspose\imaging\Graphics as Graphics;
use com\aspose\imaging\brushes\SolidBrush as SolidBrush;
use com\aspose\imaging\Rectangle as Rectangle;
use java\io\ByteArrayInputStream as ByteArrayInputStream;
class DrawingRectangle{
public static function run($dataDir=null){
# Create an instance of BmpOptions and set its various properties
$create_options = new BmpOptions();
$create_options->setBitsPerPixel(32);
# Define the source property for the instance of BmpOptions
$ary=array();
$create_options->setSource(new StreamSource(new ByteArrayInputStream($ary)));
# Create an instance of Image
$image=new Image();
$image = $image->create($create_options,100,100);
# Create an instance of Color
$color = new Color();
# Create an instance of Pen
$pen = new Pen();
# Create and initialize an instance of Graphics class
$graphic = new Graphics($image);
# Clear the image surface with Yellow color
$graphic->clear($color->getYellow());
$solid_brush = new SolidBrush();
$rectangle = new Rectangle();
# Draw a dotted rectangle shape by specifying the Pen object having red color and a rectangle structure
$graphic->drawRectangle(new Pen($color->getRed()), new Rectangle(30, 10, 40, 80));
# Draw a continuous rectangle shape by specifying the Pen object having
# solid brush with blue color and a rectangle structure
$graphic->drawRectangle(new Pen(new SolidBrush($color->getBlue())), new Rectangle(10, 30, 80, 40));
# Save all changes.
$image->save($dataDir . "DrawRectanleExample.bmp");
print "Rectangle have been drawn in image successfully!".PHP_EOL;
}
}
?>