最后活跃于 1 day ago Unlisted

capitalex's Avatar capitalex 修订了这个 Gist 1 day ago. 转到此修订

1 file changed, 22 insertions

circ.ml(文件已创建)

@@ -0,0 +1,22 @@
1 + let circ ~x ~y ~radius ?(r=0) ?(g=0) ?(b=0) screen =
2 + let t1 = ref (radius / 16) in
3 + let t2 = ref !t1 in
4 + let cx, cy = ref radius, ref 0 in
5 + while !cx >= !cy do
6 + set_pixel screen ( !cx + x) ( !cy + y) ~r ~g ~b ;
7 + set_pixel screen ( !cx + x) (-1 * !cy + y) ~r ~g ~b ;
8 + set_pixel screen (-1 * !cx + x) ( !cy + y) ~r ~g ~b ;
9 + set_pixel screen (-1 * !cx + x) (-1 * !cy + y) ~r ~g ~b ;
10 + set_pixel screen ( !cy + x) ( !cx + y) ~r ~g ~b ;
11 + set_pixel screen ( !cy + x) (-1 * !cx + y) ~r ~g ~b ;
12 + set_pixel screen (-1 * !cy + x) ( !cx + y) ~r ~g ~b ;
13 + set_pixel screen (-1 * !cy + x) (-1 * !cx + y) ~r ~g ~b ;
14 +
15 + cy := !cy + 1 ;
16 + t1 := !t1 + !cy ;
17 + t2 := !t1 - !cx ;
18 + if !t2 >= 0 then begin
19 + t1 := !t2 ;
20 + cx := !cx - 1 ;
21 + end
22 + done
上一页 下一页