5 import gfxprim
.core
as core
6 import gfxprim
.gfx
as gfx
7 import gfxprim
.backends
as backends
8 import gfxprim
.input as input
11 color
= bk
.context
.RGBToPixel(0xee, 0xee, 0xee)
12 bk
.context
.gfx
.Fill(color
)
16 fg
= bk
.context
.RGBToPixel(0xee, 0xee, 0xee)
17 bg
= bk
.context
.RGBToPixel(0, 0, 0);
19 bk
.context
.gfx
.Fill(bg
)
20 for i
in range(0, bk
.context
.h
, 10):
21 bk
.context
.gfx
.HLine(0, bk
.context
.w
, i
, fg
)
25 fg
= bk
.context
.RGBToPixel(0xee, 0xee, 0xee)
26 bg
= bk
.context
.RGBToPixel(0, 0, 0);
28 bk
.context
.gfx
.Fill(bg
)
30 for i
in range(0, bk
.context
.w
, 10):
31 bk
.context
.gfx
.VLine(i
, 0, bk
.context
.h
, fg
)
36 fg
= bk
.context
.RGBToPixel(0xee, 0xee, 0xee)
37 bg
= bk
.context
.RGBToPixel(0, 0, 0);
39 bk
.context
.gfx
.Fill(bg
)
41 for i
in range(0, 2 * max(bk
.context
.w
, bk
.context
.h
), 13):
42 bk
.context
.gfx
.Line(0, i
, i
, 0, fg
)
47 fg
= bk
.context
.RGBToPixel(0xee, 0xee, 0xee)
48 bg
= bk
.context
.RGBToPixel(0, 0, 0);
50 bk
.context
.gfx
.Fill(bg
)
52 for i
in range(10, 130, 10):
53 bk
.context
.gfx
.Rect(i
, i
, bk
.context
.w
- i
, bk
.context
.h
- i
, fg
)
58 fg
= bk
.context
.RGBToPixel(0xee, 0xee, 0xee)
59 bg
= bk
.context
.RGBToPixel(0, 0, 0);
61 bk
.context
.gfx
.Fill(bg
)
66 for i
in range(10, 90, 10):
67 bk
.context
.gfx
.Triangle(2*i
, i
, w
- 2*i
, i
, w
//2, h
- 2*i
, fg
)
72 fg
= bk
.context
.RGBToPixel(0xee, 0xee, 0xee)
73 bg
= bk
.context
.RGBToPixel(0, 0, 0);
75 bk
.context
.gfx
.Fill(bg
)
80 for i
in range(10, 70, 10):
81 bk
.context
.gfx
.Tetragon(i
, i
, w
-2*i
, i
, w
-i
, h
-i
, 2*i
, h
-i
, fg
)
86 fg
= bk
.context
.RGBToPixel(0xee, 0xee, 0xee)
87 bg
= bk
.context
.RGBToPixel(0, 0, 0);
89 bk
.context
.gfx
.Fill(bg
)
94 polygon
= [(10, 10), (10, (h
-10)//3), ((w
-10)//3, (h
-10)//2),
95 (10, 2*(h
-10)//3), (10, h
-10), ((w
-10)//3, h
-10),
96 ((w
-10)//2, 2*(h
-10)//3), (2*(w
-10)//3, h
-10),
97 (w
-10, h
-10), (w
-10, 2*(h
-10)//3), (2*(w
-10)//3, (h
-10)//2),
98 (w
-10, (h
-10)//3), (w
-10, 10), (2*(w
-10)//3, 10),
99 ((w
-10)//2, (h
-10)//3), ((w
-10)//3, 10)]
101 bk
.context
.gfx
.Polygon(polygon
, fg
)
140 bk
= backends
.BackendX11Init(None, 0, 0, 320, 240, "GFX demo", 0)
147 print("Press SPACE to draw different shape, ESC to exit")
155 if (ev
.type == input.EV_KEY
and ev
.code
== input.EV_KEY_DOWN
):
157 if (ev
.val
.val
== input.KEY_ESC
):
162 if (ev
.type == input.EV_SYS
):
163 if (ev
.code
== input.EV_SYS_QUIT
):
166 if __name__
== '__main__':