Re: Spiral

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

Este es un mensaje multipartes en formato MIME.

--------------379F6CD31019
Content-Transfer-Encoding: quoted-printable

With regards to the request for a spiral program by John Waldrep and=20
following reply by Michael Pack, I attach a short, untidy program, with=20
no type checking or otherwise but produces a simple spiral of different=20
size, turns etc.=20

However, interestingly it will not draw in BLACK! I imagine that this is=20
because BLACK is transparent. Can anybody clarify / confirm this?

Saludos (Spanish for cheers)

Adam H. Jackson

P.S. I have only been using Euphoria for the first time last week and am=20
very impressed. So far the only dispointment is the speed of the output=20
of text to the screen and input from the key board. (The buffer fills=20
faster than Euphoria can read it.) I=B4d imagine that this is because it =
is=20
controlled through DOS and not direct. Anybody got a solution or include=20
that might help?

--------------379F6CD31019
Content-Disposition: inline; filename="SPIRAL.EX"

include get.e
include graphics.e

atom check
integer turns,step,size_x,size_y
constant pi=3.141596
constant rad=pi/180  -- To convert from Radians to Degrees when multiplied by
                     -- the angle. eg. sin(90*rad)=1

function input(sequence text) -- To print a message a return a number from user
sequence inp,cur
inp={1,0}
    puts (1,text)                   -- message on screen
    while inp[1] do                 -- repeat until valid number
    cur=get_position()              -- back to position if not valid
    inp = get (0)
    position (cur[1],cur[2])
    end while
    return inp[2]
end function

-- Main part of program sorry about lazy structuring of the program but I will
-- leave something for you to do

turns=input("Number of spiral turns ")
step=input("\nSpiral steps ")
size_x=input("\nMax size x of spiral (1-320) ")
size_y=input("\nMax size y of spiral (1-200) ")

clear_screen()
integer color,x,y,x_old,y_old

check=graphics_mode(256)
bk_color(BLUE) clear_screen()

color=BROWN       -- I dont know why BLACK dosent work. (Transparent?)
for a=1 to 360*turns by step do
    if color=BROWN then color=WHITE else color=BROWN end if --Each step a color

    x=floor(320+cos(a*rad)*a/(360*turns)*size_x) -- fits screen mode
    y=floor(200+sin(a*rad)*a/(360*turns)*size_y) -- 640 x 400
    if a=1 then x_old=x y_old=y end if
    draw_line(color,{{x_old,y_old},{x,y}})
    x_old=x  y_old=y
end for
check=wait_key()




--------------379F6CD31019--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu