Re: Spiral

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sat, 9 Nov 1996, John Waldrep wrote:
>
>      I would greatly appreciate it anyone could send me a small program to
> generate a black and white spiral.

You never gave us any more info, so here's a Black and GREEN 2D spiral:
The general equation for a spiral in polar coordinates is r=theta, which
is x=r*(sin(theta)) y=r*(cos(theta)) in rectangular.  To display this on
the screen, you need to multiply x and y by a size factor and add an
offset shift the coordinate axis to the center of the screen.  In this
example the we're in 640x480x16 color mode, so we add 320 to x and 240 to
y to center the spiral on the screen.

-- spiral.ex
without type_check

include graphics.e
include select.e
include get.e
constant GRAPHICS_MODE = 18 -- VGA
atom size
atom x
atom y
-- switch to graphics screen
    if not select_mode(GRAPHICS_MODE) then
        puts(1, "needs VGA graphics\n")
        abort(1)
    end if

-- spiral
    for i = 1 to 10 by .5 do --do the spiral is different sizes
    size =i
    for r = 0 to 80 by .01  do
        x=size*r*sin(r)+320 y=size*r*cos(r)+240
        pixel(10,{x,y})
    end for

   --Don't clear the screen the last time.
   if i <10 then clear_screen() end if

   end for
   x=wait_key()

    if graphics_mode(-1) then
    end if
---------------------------------
see, I didn't go to college for nothing...
It cost me THOUSANDS AND THOUSANDS of dollars...
(yes, I have a math degree)

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu