/drawdot /drawrect bug? - 27/12/11 08:39 AM
ok so I was thinking, two circles touching that are the same size have a center to center equivalence of the diameter of one of those circles (or two radius) so knowing that, I tried to draw stacked circles. drawrect -e seems to go by corner rather than center, so the radius has to be subtracted from the x and y.
Take the below code and try /circletest 1-3
1 = drawrect
2 = drawdot
3 = custom
now if you really wanna see this clash, uncomment the drawdot line so you get a drawdot inside the chosen method to see how off it is.
You'll notice the custom draw routine is more precise.
Take the below code and try /circletest 1-3
1 = drawrect
2 = drawdot
3 = custom
Code:
alias drawcircle { var %r = $3 , %x = $4 , %y = $5 , %f = 1 - %r var %ddfx = 1 , %ddfy = -2 * %r var %cx = 0 , %cy = %r drawdot $1-2 1 %x $calc(%y + %r) drawdot $1-2 1 %x $calc(%y - %r) drawdot $1-2 1 $calc(%x + %r) %y drawdot $1-2 1 $calc(%x - %r) %y while (%cx < %cy) { if (%f >= 0) { dec %cy inc %ddfy 2 inc %f %ddfy } inc %cx inc %ddfx 2 inc %f %ddfx drawdot $1-2 1 $calc(%x + %cx) $calc(%y + %cy) drawdot $1-2 1 $calc(%x - %cx) $calc(%y + %cy) drawdot $1-2 1 $calc(%x + %cx) $calc(%y - %cy) drawdot $1-2 1 $calc(%x - %cx) $calc(%y - %cy) drawdot $1-2 1 $calc(%x + %cy) $calc(%y + %cx) drawdot $1-2 1 $calc(%x - %cy) $calc(%y + %cx) drawdot $1-2 1 $calc(%x + %cy) $calc(%y - %cx) drawdot $1-2 1 $calc(%x - %cy) $calc(%y - %cx) } ;drawfill $1-2 $2 $3 $4 } alias circletest { var %wx = 320 , %wy = 240 , %cx = %wx / 2 , %cy = %wy / 2 window -dpf @CircleTest -1 -1 %wx %wy clear @circletest var %x = 0 , %ball.r = 11.25 , %ball.d = %ball.r * 2 while (%x < 5) { var %y = %x + 1 , %z = 0 , %sy = $calc(%cy - (%ball.r * %y)) while (%z < %y) { inc %z ;========== uncomment this to test offness... ;drawdot @CircleTest $iif($calc(%z % 2),5,4) %ball.r $calc(%cx + %ball.r * 2 * %x) $calc(%sy + %ball.r * 2 * %z) ;========== uncomment this to test offness... if (!$1 || $1 = 1) { drawrect -e @CircleTest $iif($calc(%z % 2),10,11) 1 $calc(%cx - %ball.r + %ball.r * 2 * %x) $calc(%sy - %ball.r + %ball.r * 2 * %z) %ball.d %ball.d } elseif ($1 = 2) drawdot @CircleTest $iif($calc(%z % 2),5,4) %ball.r $calc(%cx + %ball.r * 2 * %x) $calc(%sy + %ball.r * 2 * %z) elseif ($1 = 3) drawcircle @CircleTest $iif(%x = 1,3,$iif(%x <= 2,7,$iif($calc(%z % 2),3,7))) %ball.r $calc(%cx + %ball.r * 2 * %x) $calc(%sy + %ball.r * 2 * %z) } inc %x } }
now if you really wanna see this clash, uncomment the drawdot line so you get a drawdot inside the chosen method to see how off it is.
You'll notice the custom draw routine is more precise.