-
Notifications
You must be signed in to change notification settings - Fork 1
/
Drawing02.nim
46 lines (38 loc) · 1.01 KB
/
Drawing02.nim
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
import random
import fltk_main
#test of:
# DrawSetFont
# DrawStr
# DrawStrRot
proc DrawCB (self: pointer): long{.cdecl.} =
var
w: long =Fl_WidgetGetW(self)
h: long =Fl_WidgetGetH(self)
deg: long = 180
i, size, x, y: long
font: FL_FONT
DrawPushClip(0, 0, w, h)
DrawRectFillRGBColor(0, 0, w, h, rand(255), rand(255), rand(255))
for font in 0 .. 15:
size = long(6 + rand(70))
DrawSetFont(cast[FL_FONT](font), size)
for i in 0 .. 1:
DrawSetRGBColor(rand(255), rand(255), rand(255))
x = rand(int(w))
y = rand(int(h))
if i == 1 :
DrawStr("DrawStr()", x, y)
else:
DrawStrRot(deg, "DrawStrRot()", x, y)
deg += 5
DrawPopClip()
return 1
#
# main
#
# for drawing it#s a good idea to use a flicker free double buffered window
var win = Fl_Double_WindowExNew(640, 480, "Drawing02.nim resize me ...")
Fl_Double_WindowExSetDrawCB win, DrawCB
Fl_GroupSetResizable win, win
Fl_WindowShow win
Fl_Run()