Computer Science Canada

Draw a circle

Author:  recneps [ Mon Mar 22, 2004 4:30 pm ]
Post subject:  Draw a circle

Draw a circle the cool way! (dot by dot Very Happy)
i know its not much but check it out.
(I know, i actually LEARNED something from math class Very Happy)

code:
var x2, y2:int:=100
function circleify(x:int,y:int):int
var z:int:=round((x2-x)**2+(y2-y)**2)
result round(z**0.5)
end circleify


for x:1..maxx
for y:1..maxy
if circleify (x,y) = 100 then
drawdot(x,y,7)
end if
end for
end for

where x2,y2 is the location of the centre
and circleify(x,y) =number
where number is the radius
Very Happy(i know its completely useless, but meh.

Author:  Cervantes [ Mon Mar 22, 2004 7:23 pm ]
Post subject: 

oh my... god......

spencer, that is.... amazing.
Laughing
nono im dead serious. That's really good that you are using functions AND stuff you learned from math class. Very Happy[/b]

Author:  Delos [ Mon Mar 22, 2004 7:54 pm ]
Post subject: 

Nice, nice...
Now try the same using trig. It's a bit more fun that the usual conics type of algebra.

Author:  programer007 [ Tue Mar 23, 2004 8:06 am ]
Post subject: 

very nice,.... i found it worked better iof you changed the first line to = 200 not 100 but kept everything else the same... this way it dont draw out of bounds.....

VERY NICE>>.... thats beginning gr.11 work there... using functions and integrating math,,, +10 BITS!

Author:  recneps [ Tue Mar 23, 2004 9:23 pm ]
Post subject: 

Dont say trig :/ (i hate math now as it is) and thanks ;D we're almost at parabola's! I can see mario jumps on the horizon! look out ppl! Sidescroller V2 Coming soon!

Author:  recneps [ Tue Mar 23, 2004 9:37 pm ]
Post subject: 

Here, new version. Call it by using

code:
circlify(centrex,centrey,radius,colour)

Very Happy

Author:  jonos [ Tue Mar 23, 2004 10:21 pm ]
Post subject: 

ooh ooh, nice... good use of math you have learned. we're still on feasible regions, which sucks Sad

Author:  zylum [ Wed Mar 24, 2004 12:08 am ]
Post subject: 

here's a way using lines :

code:

procedure drawCircle (centerx, centery, diam, c : int)
    var x, y, oldx, oldy : real
    oldx := cos (0) * diam + centerx
    oldy := sin (0) * diam + centery
    for i : 1 .. 360
        x := cosd (i) * diam + centerx
        y := sind (i) * diam + centery
        drawline (round (oldx), round (oldy), round (x), round (y), c)
        oldx := x
        oldy := y
    end for
end drawCircle

drawCircle (maxx div 2, maxy div 2, 100, 7)


here's a way to do fill oval

code:

procedure drawCircle (centerx, centery, diam, c : int)
    var x, y, oldx, oldy : real
    for i : 1 .. 360 * (diam div 50)
        x := cosd ((i / (diam / 50))) * diam
        y := sind ((i / (diam / 50))) * diam + centery
        drawline (round (x) + centerx, round (y), round (-x) + centerx, round (y), c)
    end for
end drawCircle

drawCircle (maxx div 2, maxy div 2, 200, 7)


Razz

-zylum

Author:  recneps [ Wed Mar 24, 2004 3:48 pm ]
Post subject: 

Arg, i really gotta learn sine and cosine. All the cool programs seem to use it.... Sad

Author:  jonos [ Wed Mar 24, 2004 3:52 pm ]
Post subject: 

just wait till trig in math... thats where everything comes together.

Author:  WhatAmIDoing [ Thu Mar 25, 2004 12:18 pm ]
Post subject: 

the fill circle needs a delay of 10 or 15 on my comp other than that it's pretty good. oh and what gr.11 are you in i spent untill feb. learning loops and if statements we hust started string manipulation and my teacher don't belive in making games.

Author:  recneps [ Fri Mar 26, 2004 4:04 pm ]
Post subject: 

im in 10 and i took the initiative to teach myself some more (sadly no higher than gr 10 is offered at my school.) i had gr 10 last sem, and gr math this sem Wink
We did parabola's today. so heres drawparabola!!!
code:

procedure drawparabola(position:int,height:int,angle:real)
var y:real:=0
%const angle := -.1
%const position := 100
%const height := 150
for x:1..200
y:=(angle*((x-position)**2))+height
drawdot(round(x),round(y),7)
end for
end drawparabola

drawparabola(100,150,-.1)

And the commented lines are the "default" ones, in case you change em and dont like it Wink

Author:  the_short1 [ Fri Mar 26, 2004 6:40 pm ]
Post subject: 

that parabola is kinda simple...

drawline at mid point to midpoint +25 to the right
then draw a line to the left... +25 and each repetition of loop lower that 25 -1 and add one to hight...

all the ones u did look nice tho... good job..

and ur cicle one lookz better then zylum.... his is not as smooth... A FIRST!
but zylums is way more complex

Author:  recneps [ Fri Mar 26, 2004 7:37 pm ]
Post subject: 

we JUST learned parabolas, itll improve with time Wink

Author:  Hackster [ Sat Mar 27, 2004 1:04 am ]
Post subject: 

Holy shinikeys man ... one day of parabolas and you're making programs with them ... that is a very good sign!!! (Youre gunna make a great programmer!) Very Happy

Author:  recneps [ Sat Mar 27, 2004 11:01 am ]
Post subject: 

Well we havent even technically got into the equations of em, my friend is this math whiz and he gave me the equation Wink

Author:  something [ Wed Mar 31, 2004 9:12 pm ]
Post subject: 

wow...just...wow

I hate to do this but couldn't it be done simplier

something like:

code:
for a : 0..360
drawarc (50,50, 50,50,0,a, 7)
delay (5)
end for


Just wanted to feel smart

-Sammi

Author:  the_short1 [ Thu Apr 01, 2004 9:53 pm ]
Post subject: 

no wahts fun ny... i was just about to post that so i went into this thread and ,, there... u did it......... realy realy scary...

i made a cool ball rotation with filled arcs...
for by upcoming program.. i wanted the balls that are bouncing around to be half one color half another color... and have the colors rotating.....

and that is why i was about to post... scray.... brains are alike,.,.

Author:  zylum [ Thu Apr 01, 2004 10:35 pm ]
Post subject: 

something wrote:
wow...just...wow

I hate to do this but couldn't it be done simplier

something like:

code:
for a : 0..360
drawarc (50,50, 50,50,0,a, 7)
delay (5)
end for


Just wanted to feel smart

-Sammi



an arc isn't the same thing as a parabola -_-


- zylum

Author:  recneps [ Fri Apr 02, 2004 9:07 pm ]
Post subject: 

a parabola is a series of points, an arc is just a line Smile
like when you throw a ball up, it goes up fast, slows down, then drops. if you measure height at each second, you get a series of points on a parabola. You cant throw a ball in an arc that way. Like say you were drawing a circle, and you wanted it to go up and then down again, you would use parabola, because the x and y change so its smooth.
Yes, i know thats a really long explanation and could probably be left off after the first sentence. But ok Very Happy

Author:  zylum [ Sat Apr 03, 2004 5:13 pm ]
Post subject: 

well both an arc and a parabola are a series of points Confused in fact, a line is just a series of points

Author:  recneps [ Sat Apr 03, 2004 8:09 pm ]
Post subject: 

ok let me rephrase that. a parabola is drawn point by point throughout a loop. an arc is drawn once (at least with the drawarc command) Very Happy

Author:  apomb [ Sun Apr 11, 2004 2:42 pm ]
Post subject: 

Hey, i know this thread is a little old, but i didn't want to make another thred, I made a parabola proggy too, its like a spinnint thing, check it out
code:
View.Set ("nooffscreenonly,graphics:max;max")
loop
    var a : int := 0
    var x, i : int := Rand.Int (32, 103)
    loop
        x := 25
        cls
        loop
            x -= 1
            Draw.FillOval (a * x + maxx div 2, - (x * x) + maxy - 4, 5, 5, i)
            exit when x = -25
        end loop
        delay (20)
        a += 1
        exit when a = 17
    end loop
    a := 17
    loop
        x := 25
        cls
        loop
            x -= 1
            Draw.FillOval (a * x + maxx div 2, - (x * x) + maxy - 4, 5, 5, i)
            exit when x = -25
        end loop
        delay (20)
        a -= 1
        exit when a = 0
    end loop
end loop

Author:  recneps [ Tue Apr 13, 2004 2:55 pm ]
Post subject: 

thats pretty sweet ;D Have some bitsss

(and whoever said "if you give bits, you receive bits". You're 100% right Wink Everyone GIVE BITS!)

Author:  apomb [ Mon Apr 19, 2004 2:34 pm ]
Post subject: 

hey thanks man, i didn't see this post untill now! ya , i gave bits and now i'm recieving bits!! here is another quote like that " If you want something, you must give it away"

Author:  the_short1 [ Mon Apr 19, 2004 3:12 pm ]
Post subject: 

neat compswiz..... ill post some of my attemps at making cool sine curves here soon ok???

here have some bits.... (compwizz) cuz i made that parabola b4 i could (iu was thinking on making it ) Wink


: