-
Notifications
You must be signed in to change notification settings - Fork 3
/
dbngraphics.dbn
58 lines (55 loc) · 1013 Bytes
/
dbngraphics.dbn
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
// dbngraphics
command triangle h1 v1 h2 v2 h3 v3
{
line h1 v1 h2 v2
line h2 v2 h3 v3
line h3 v3 h1 v1
}
command rectangle left bot right top
{
line left bot right bot
line right bot right top
line right top left top
line left top left bot
}
command circlepixels cx cy dx dy v
{
set [(cx+dx) (cy+dy)] v
set [(cx+dx) (cy-dy)] v
set [(cx-dx) (cy+dy)] v
set [(cx-dx) (cy-dy)] v
set [(cx+dy) (cy+dx)] v
set [(cx+dy) (cy-dx)] v
set [(cx-dy) (cy+dx)] v
set [(cx-dy) (cy-dx)] v
}
command circle cx cy radius v
{
set x 0
set y radius
set d (1-radius)
circlepixels cx cy x y v
// 707/1000 approximates square root of 0.5 = cos(45)
repeat x 0 (radius*707/1000)
{
set tempd d
smaller? tempd 0
{
set d (d+(2*x)+3)
}
notsmaller? tempd 0
{
set d (d+(2*(x-y))+5)
set y (y-1)
}
circlepixels cx cy x y v
}
}
command testdbngraphics
{
field 2 2 98 98 15
pen 100
triangle 50 96 50 4 96 50
circle 50 50 46 100
rectangle 14 23 68 77
}