- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
Latest commit
59 lines (52 loc) · 1.21 KB
/
Copy pathinit.lua
File metadata and controls
59 lines (52 loc) · 1.21 KB
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
require'torch'
require'dok'
require'image'
require'xlua'
localhelp_desc=[[
Drawing primitives
]]
draw= {}
-- load C lib
require'libdraw'
functiondraw.line(im, x1, y1, x2, y2, r, g, b)
r=ror0
g=gor0
b=bor0
im.libdraw.drawLine(im, x1, y1, x2, y2, r, g, b)
end
functiondraw.point(im, x, y, radius, r, g, b)
localradius2= (radius-1)*(radius-1)
fordx=-radius+1,radius-1do
if (x+dx>=1) and (x+dx<=im:size(3)) then
fordy=-radius+1,radius-1do
if (y+dy>=1) and (y+dy<=im:size(2)) then
ifdx*dx+dy*dy<=radius2then
im[1][y+dy][x+dx] =r
im[2][y+dy][x+dx] =g
im[3][y+dy][x+dx] =b
end
end
end
end
end
end
functiondraw.circle(im, x, y, radius, r, g, b, thickness)
thickness=thicknessor1
localn=20
localdelta=2*math.pi/n
localalpha=0
fori=1,ndo
draw.line(im, x+radius*math.cos(alpha),
y+radius*math.sin(alpha),
x+radius*math.cos(alpha+delta),
y+radius*math.sin(alpha+delta),
r, g, b)
alpha=alpha+delta
end
end
functiondraw.testme()
require'image'
locallena=image.lena()
draw.line(lena, 100, 200, 400, 230, 1, 1, 1)
image.display(lena)
end