drawcircle 
	 
	
		| Author | 
		Message | 
	 
		 
		bored_hacker
 
  
 
    
		 | 
		
		
			
				  Posted: Sun May 29, 2005 2:04 pm    Post subject: drawcircle  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				i got bored so i made this proc to draw a circle. its practically worthless except for the way you see it drawn, some people would think its cool.   
 
 
	  | code: | 	 		  proc drawcircle (x, y, radius, col : int)
 
    var i : real
 
    for q : 0 .. 72000
 
        i := q / 200
 
        drawdot (round (cosd (i) * radius) + x, round (sind (i) * radius) + y, col)
 
    end for
 
end drawcircle  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		Cervantes
 
  
 
    
		 | 
		
		
			
				  Posted: Sun May 29, 2005 3:10 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				drawfillcircle
 
	  | Turing: | 	 		  
proc drawfillcircle  (x, y, radius, clr  : int)
    var row  : real := -radius  %start at bottom of the circle
    var col  : real := 0. 0
    var dir  := 1    %1 is right, -1 is left
    var dist  : real
    loop
        dist  := (row  **  2 + col  **  2) **  0. 5
        if dist <= radius  then
            drawdot (round (x + col ), round (y + row ), clr )
        elsif dist >= radius  then
            dir * = - 1
            row + = 1
            loop    %jump back into the circle
                col + = dir
 
                dist  := (row  **  2 + col  **  2) **  0. 5
                exit when dist <= radius  or row >= radius
             end loop
        end if
        col + = dir
         exit when row >= radius
     end loop
end drawfillcircle
 
drawfillcircle  (maxx div 2,  maxy div 2,  maxy div 2,  green)
  | 	  
 
 
Would be a lot faster with more math and using lines, mind you.  Or even using math and pixels, but once you've figured out how far the pixels must go (given a certain row and radius, using some math) you could just draw a line of pixels.  That would be a lot faster, I'd imagine.  Someone else can give that a try.   | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |