-
Notifications
You must be signed in to change notification settings - Fork 57
/
sample_arc.jl
41 lines (33 loc) · 910 Bytes
/
sample_arc.jl
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
## header to provide surface and context
using Cairo
c = CairoRGBSurface(256,256);
cr = CairoContext(c);
save(cr);
set_source_rgb(cr,0.8,0.8,0.8); # light gray
rectangle(cr,0.0,0.0,256.0,256.0); # background
fill(cr);
restore(cr);
## original example, following here
xc = 128.0;
yc = 128.0;
radius = 100.0;
angle1 = 45.0 * (pi/180.0); # angles are specified
angle2 = 180.0 * (pi/180.0); # in radians
set_line_width(cr, 10.0);
arc(cr, xc, yc, radius, angle1, angle2);
stroke(cr);
# draw helping lines
set_source_rgba(cr, 1, 0.2, 0.2, 0.6);
set_line_width(cr, 6.0);
arc(cr, xc, yc, 10.0, 0, 2*pi);
fill(cr);
arc(cr, xc, yc, radius, angle1, angle1);
line_to(cr, xc, yc);
arc(cr, xc, yc, radius, angle2, angle2);
line_to(cr, xc, yc);
stroke(cr);
## mark picture with current date
move_to(cr,0.0,12.0);
set_source_rgb(cr, 0,0,0);
show_text(cr,Libc.strftime(time()));
write_to_png(c,"sample_arc.png");