Computer Science Canada

drawoval_o

Author:  octopi [ Wed Jun 09, 2004 7:12 pm ]
Post subject:  drawoval_o

Hey, I made a custom drawoval command.

It works with float values for the radii.
Allows you to make thick ovals. (float values for thickness, althought they generally get rounded away.)


code:
procedure drawoval_o (x:int,y:int,xrad:real,yrad:real,thick:real,col:int)
  var halfthick:real:=0.5*thick
  var xn,yn:real
  for t:1..round(4*3.141592654*((xrad+yrad)/2)*(5+round(thick)))
    xn:=xrad* cos (t)+x+Rand.Int(round(-halfthick),round(halfthick))
    yn:=yrad* sin (t)+y+Rand.Int(round(-halfthick),round(halfthick))
    drawdot(round(xn),round(yn),col)
  end for
end drawoval_o

drawoval_o(200,200,40.5,40.5,0,45)
drawoval_o(400,200,200,200,2,45)


If someone can find better values to use as a limit for 't' (this is a parametric approach to the circle.) (I'm using approx the perimeter of the circle times the thickness+5)

Author:  the_short1 [ Wed Jun 09, 2004 8:58 pm ]
Post subject: 

cant u just go:

to make 4 thickness

for a : 50..54
drawoval (100,100,a,a,black)
end for

??


that and urs had a few dots missing * not solid color...

but good stuf...

Author:  octopi [ Wed Jun 09, 2004 9:01 pm ]
Post subject: 

try

for a: 20..25
drawoval (100,100,a,a,black)
end for





notice the problem, the number of dots can be increase with my method to provide complete coverage.....and I think I have a solution for my dot problem, (working on it right now)

Author:  octopi [ Wed Jun 09, 2004 9:24 pm ]
Post subject: 

code:
procedure drawoval_o (x:int,y:int,xrad:real,yrad:real,thick:real,col:int)
  var halfthick:real:=0.5*thick
  var xn,yn:real
  var perm:real
  perm:=2*Math.PI* sqrt( (xrad**2 + yrad**2)/2)
  for z: -round(halfthick) .. round(halfthick)
  for t:1..round(perm)*((thick div 10)+1)
    xn:=(xrad+z)* cos (t)+x
    yn:=(yrad+z)* sin (t)+y   
    drawdot(round(xn),round(yn),col)
  end for
  end for
end drawoval_o

drawoval_o(200,200,40.5,40.5,20,black)



meh this isn't perfect either....


: