4 The python binding maps mostly to the C API with the 'GP_' prefix stripped.
6 The gfx module adds methods to the gfx context submodule.
8 NOTE: You may want to see the link:coordinate_system.html[coordinate system]
14 All drawing functions takes a 'pixel' value (to describe color) which
15 link:core_python.html#Colors_and_Pixels[can be obtained], for a particular
16 pixel type (context), from a RGB triplet.
18 All drawing functions are clipped. Drawing outside of a context is no-op.
20 WARNING: Drawing functions takes strictly integer coordinates, make sure that
21 all divisions are integer divisions (i.e. use // instead of /) to
22 ensure portability with Python 3.X.
28 -------------------------------------------------------------------------------
29 import gfxprim.gfx as gfx
31 context.gfx.HLine(x0, x1, y, pixel)
33 -------------------------------------------------------------------------------
35 Draws a horizontal line from 'x0' to 'x1' at 'y'.
38 -------------------------------------------------------------------------------
39 import gfxprim.gfx as gfx
41 context.gfx.VLine(x, y0, y1, pixel)
43 -------------------------------------------------------------------------------
45 Draws a vertical line from 'y0' to 'y1' at 'x'.
49 -------------------------------------------------------------------------------
50 import gfxprim.gfx as gfx
52 context.gfx.Line(x0, y0, x1, y1, pixel)
54 -------------------------------------------------------------------------------
56 Draws a line from x0, y0 to x1, y1.
59 -------------------------------------------------------------------------------
60 import gfxprim.gfx as gfx
62 context.gfx.Rect(x0, y0, x1, y1, pixel)
64 -------------------------------------------------------------------------------
66 Draws a rectangle defined by two points.
69 -------------------------------------------------------------------------------
70 import gfxprim.gfx as gfx
72 context.gfx.Triangle(x0, y0, x1, y1, x1, y2, pixel)
74 -------------------------------------------------------------------------------
76 Draws a triangle defined by three points.
79 -------------------------------------------------------------------------------
80 import gfxprim.gfx as gfx
82 context.gfx.Tetragon(x0, y0, x1, y1, x1, y2, x3, y3, pixel)
84 -------------------------------------------------------------------------------
86 Draws a tetragon defined by four points.
89 -------------------------------------------------------------------------------
90 import gfxprim.gfx as gfx
92 context.gfx.Polygon([x0, y0, x1, y1, ...], pixel)
94 context.gfx.Polygon([(x0, y0), (x1, y1), ...], pixel)
96 -------------------------------------------------------------------------------
98 Draws a polygon defined by points, points can be either flat list of 2N
99 integers or list of N tuples.
102 -------------------------------------------------------------------------------
103 import gfxprim.gfx as gfx
105 context.gfx.Circle(x, y, r, pixel)
107 -------------------------------------------------------------------------------
112 -------------------------------------------------------------------------------
113 import gfxprim.gfx as gfx
115 context.gfx.Ellipse(x, y, a, b, pixel)
117 -------------------------------------------------------------------------------
122 -------------------------------------------------------------------------------
123 import gfxprim.gfx as gfx
125 context.gfx.Ring(x, y, r1, r2, pixel)
127 -------------------------------------------------------------------------------
135 -------------------------------------------------------------------------------
136 import gfxprim.gfx as gfx
138 context.gfx.Fill(pixel)
140 -------------------------------------------------------------------------------
142 Fills context with particular 'pixel' value.
145 -------------------------------------------------------------------------------
146 import gfxprim.gfx as gfx
148 context.gfx.FillRect(x0, y0, x1, y1, pixel)
150 -------------------------------------------------------------------------------
152 Fills a rectangle defined by two points.
155 -------------------------------------------------------------------------------
156 import gfxprim.gfx as gfx
158 context.gfx.FillTriangle(x0, y0, x1, y1, x1, y2, pixel)
160 -------------------------------------------------------------------------------
162 Draws a filled triangle defined by three points.
165 -------------------------------------------------------------------------------
166 import gfxprim.gfx as gfx
168 context.gfx.FillTetragon(x0, y0, x1, y1, x1, y2, x3, y3, pixel)
170 -------------------------------------------------------------------------------
172 Draws a filled tetragon defined by four points.
175 -------------------------------------------------------------------------------
176 import gfxprim.gfx as gfx
178 context.gfx.FillPolygon([x0, y0, x1, y1, ...], pixel)
180 context.gfx.FillPolygon([(x0, y0), (x1, y1), ...], pixel)
182 -------------------------------------------------------------------------------
184 Fills a polygon defined by points, points can be either flat list of 2N
185 integers or list of N tuples.
188 -------------------------------------------------------------------------------
189 import gfxprim.gfx as gfx
191 context.gfx.FillCircle(x, y, r, pixel)
193 -------------------------------------------------------------------------------
198 -------------------------------------------------------------------------------
199 import gfxprim.gfx as gfx
201 context.gfx.FillEllipse(x, y, a, b, pixel)
203 -------------------------------------------------------------------------------
208 -------------------------------------------------------------------------------
209 import gfxprim.gfx as gfx
211 context.gfx.FillRing(x, y, r1, r2, pixel)
213 -------------------------------------------------------------------------------
215 Fills a ring, i.e. area enclosed between two circles.
217 TIP: See gfx module link:example_py_gfx.html[example].