-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics.spin2
110 lines (84 loc) · 2.71 KB
/
graphics.spin2
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
Graphics Object
Provides wrapper methods for the driver methods
Driver methods are mapped using set_pointer(index,ptr)
The GUI object uses these constants to map the method with the correct variable
(they should match the order of the variables in the DAT section)
'Drawing Methods Constants
'#0, CLEAR_SCREEN, SET_FOREGROUND_COLOR, SET_BACKGROUND_COLOR, SET_WINDOW, FILL_WINDOW, SET_COL_ROW
'#6, DRAW_CHAR, DRAW_STRING, DRAW_ICON, DRAW_PIXEL, DRAW_LINE
'#11, DRAW_CIRCLE, DRAW_RECTANGLE, FILL_RECTANGLE, SELECT_FONT_SIZE, MAX_METHODS
}
DAT
'These variables hold a method pointer to the drivers corresponding methods
{
The nice thing about this is that variables declared in a DAT section
keep their value, as they are common to all instances of the object
(as with the methods), so this whole object works as a Singleton Object
that is shared among all other objects that instance it.
This is why only GUI has to call set_pointer to store the method pointers.
}
_clear_screen long 0
_set_foreground_color long 0
_set_background_color long 0
_set_window long 0
_fill_window long 0
_set_col_row long 0
_draw_char long 0
_draw_string long 0
_draw_icon long 0
_draw_pixel long 0
_draw_line long 0
_draw_circle long 0
_draw_rectangle long 0
_fill_rectangle long 0
_select_font_size long 0
_fill_circle long 0
_draw_fast_hline long 0
_draw_fast_vline long 0
_send_image long 0
PUB set_pointer(index, ptr)|addr
''Store method pointer in global variable
addr := @_clear_screen + 4*index
LONG[addr] := ptr
''+--------------------------------------------------------------------+
'' Driver's wrapper methods
''+--------------------------------------------------------------------+
PUB clear_screen()
_clear_screen()
PUB set_foreground_color(bgr)
_set_foreground_color(bgr)
PUB set_background_color(bgr)
_set_background_color(bgr)
PUB set_window(xs,ys,xe,ye)
_set_window(xs,ys,xe,ye)
PUB fill_window(bgr)
_fill_window(bgr)
PUB set_col_row(xs,ys)
_set_col_row(xs,ys)
PUB draw_char(char)
_draw_char(char)
PUB draw_string(str)
_draw_string(str)
PUB draw_icon(img, w, h)
_draw_icon(img,w,h)
PUB draw_pixel(x, y, rgb)
_draw_pixel(x,y,rgb)
PUB draw_line(xs,ys,xe,ye,rgb)
_draw_line(xs,ys,xe,ye,rgb)
PUB draw_circle(xc,yc,r,rgb)
_draw_circle(xc,yc,r,rgb)
PUB draw_rectangle(xs,ys,xe,ye,rgb)
_draw_rectangle(xs,ys,xe,ye,rgb)
PUB fill_rectangle(xs,yx,xe,ye,rgb)
_fill_rectangle(xs,yx,xe,ye,rgb)
PUB select_font_size(s)
_select_font_size(s)
PUB fill_circle(xc,yc,r,rgb)
_fill_circle(xc,yc,r,rgb)
PUB draw_fast_hline(x,y,l,rgb)
_draw_fast_hline(x,y,l,rgb)
PUB draw_fast_vline(x,y,l,rgb)
_draw_fast_vline(x,y,l,rgb)
PUB send_image(imagePtr,x,y,w,h)
_send_image(imagePtr,x,y,w,h)