Skip to content

Commit 2a37568

Browse files
author
Evgeniy Sidenko
committed
Aspose.Imaging for Python via .NET 25.7 is released!
The new version supports drawing operations over a VectorImage with the class Graphics.
1 parent c0aa753 commit 2a37568

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# GROUP: TEST_FILE_FORMATS
2+
from aspose.imaging import Graphics, Color, Pen, Rectangle, PointF, Font
3+
from aspose.imaging.brushes import SolidBrush
4+
from aspose.imaging.fileformats.svg import SvgImage
5+
import os
6+
7+
8+
# Initialization
9+
def get_data_root_dir_local():
10+
if 'BASE_DIR' in os.environ:
11+
return os.environ["BASE_DIR"]
12+
return "."
13+
14+
15+
if 'get_data_root_dir' not in dir():
16+
get_data_root_dir = get_data_root_dir_local
17+
18+
if 'get_output_dir' not in dir():
19+
get_output_dir = get_data_root_dir_local
20+
21+
# Example code:
22+
output_path = get_output_dir()
23+
24+
fileName = "test.svg"
25+
output_file = os.path.join(get_output_dir(), fileName)
26+
27+
with SvgImage(100,100) as vectorImage:
28+
g = Graphics(vectorImage)
29+
g.fill_rectangle(SolidBrush(Color.light_yellow), 10, 10, 80, 80)
30+
g.draw_rectangle(Pen(Color.red, 4), 10, 10, 80, 80)
31+
g.fill_ellipse(SolidBrush(Color.light_green), 20, 20, 60, 60)
32+
g.draw_ellipse(Pen(Color.green, 2), 20, 20, 60, 60)
33+
g.fill_pie(SolidBrush(Color.light_blue), Rectangle(30, 30, 40, 40), 0, 45)
34+
g.draw_pie(Pen(Color.blue, 1), Rectangle(30, 30, 40, 40), 0, 45)
35+
g.draw_line(Pen(Color.dark_red, 1), 10, 20, 90, 20)
36+
g.draw_lines_f(Pen(Color.dark_red, 1), [ PointF(10, 90), PointF(20, 80), PointF(30, 90) ])
37+
g.draw_polygon_f(Pen(Color.dark_red, 1), [ PointF(90, 90), PointF(80, 80), PointF(70, 90) ])
38+
g.draw_string("Hello World!", Font("Arial", 14), SolidBrush(Color.dark_blue), PointF(10, 50))
39+
g.draw_arc(Pen(Color.brown, 1), Rectangle(30, 30, 40, 40), 135, -90)
40+
41+
vectorImage.save(output_file)
42+
43+
if 'SAVE_OUTPUT' not in os.environ:
44+
os.remove(output_file)

0 commit comments

Comments
 (0)