From a math graphics program I wrote

Phoenix

Active Member
Messages
631
From a math graphics program I wrote

I call this one

colour = rad(x +halfx/2,y-halfy*.8)+power(-1,x+y)*rad(x,y+halfy*.8)
-rad(x - halfx/2,y-halfy*.8)*sin(zoom)

:p
 

Phoenix

Active Member
Messages
631
From a math graphics program I wrote

Here is the program
-----------------------------
-- Polygon Pattern Program --
-----------------------------

-- press space bar to see a new pattern
-- press any other key to quit

constant GRAPHICS_MODE = 19 -- SVGA, if this fails try mode 18
? ?-- see also euphoria\include\graphics.e
without type_check

include music.e
include graphics.e
include select.e
include machine.e
include image.e

-- use_vesa(1) -- for ATI cards

constant TRUE = 1
sequence config, pal, scale
atom mode, white
integer code

scale = {360,378,405,432,450,480,504,540,576,600,648,680,720}
mode = 0
white = 7.8028549
function mag( atom number )
if number < 0 then
return -number
end if
return number
end function

function angle( atom x, atom y, atom n)
n = n/PI*126
if x != 0 then
if x < 0 then
?if y = 0 then
?return 2*n*PI
?end if
?return n*(arctan(y/x)+2*PI)
end if
?if y = 0 then
?return n*PI
?end if
return n*(arctan(y/x)+PI)
end if
if y > 0 then
return 3*n*PI/2
end if
return n*PI/2
end function
function inv( atom v )
if v != 0 then
return 1/v
end if
return v
end function
function cut( atom top, atom low, atom num )
if num > top then
return top
elsif num < low then
return low
else
return num
end if
end function
function rad( atom x, atom y )

return (power(power( x,2) + power (y,2),0.5))

end function
function bounce ( atom deg, atom base, atom case )
return floor(deg*power(power(case,2),.5)+base )
end function

function poly_pattern()
?integer color, ncolors,fully, fullx, halfy, halfx, key,
red, grn, blu, n
atom zoom, speed,increase, x, y, Time, rad3, rad2,Sound,colour,
? ?x2,y2

?config = video_config()
? ncolors = config[VC_NCOLORS]
n = floor(ncolors/6)
fully = config[VC_YPIXELS]
fullx = config[VC_XPIXELS]
halfy = config[VC_YPIXELS]/2
halfx = config[VC_XPIXELS]/2
? color = 1
? ?Time = time()
? zoom = 1
? ?rad2 = power(2,0.5)
rad3 = power(3,0.5)
increase = 1
speed = 1.005
Sound = 1
--Hue Palette
for hue = 0 to ncolors - 1 do
?
?
?red = bounce(64/n,-64,hue-3*n)
?grn = bounce(-64/n,128,hue-2*n)
?blu = bounce(-64/n,128,hue-4*n)

?red = cut(63,0,red)
?grn = cut(63,0,grn)
?blu = cut(63,0,blu)
?

pal = palette( hue, {red,grn,blu})
end for
?x2 = 1
?y2 = 1
?clear_screen()
?while TRUE do
for i = 1 to fullx do
for j = 1 to fully do
?x = i - halfx
?y = j - halfy

?
?if mode = 0 then
? ? ? ? ? ? colour = rad(x +halfx/2,y-halfy*.8)+power(-1,x+y)*rad(x,y+halfy*.8)
?-rad(x - halfx/2,y-halfy*.8)*sin(zoom)
?elsif mode = 1 then
? colour = inv(rad(x,y))
? ? ? ? ? ?elsif mode = 2 then
? ? ? ? ? ? colour =power((rad(x,y)),2)
? ? ? ? ? ?elsif mode = 3 then
? ? ? ? ? ? colour = power(inv(rad(x,y)),2)
? ? ? ? ? ?elsif mode = 4 then
? ? ? ? ? ? colour = rad(x*x,y*y)
?elsif mode = 5 then
? colour = cos(y/30*zoom)*10+sin(x/30*zoom)*10
? ? ? ? ? ?else
? ? ? ? ? ? colour = inv(rad(x,y))+ angle(x,y,1)/zoom
? ? ? ? ? ?
? ? ? ? ? ?end if
?
?color = remainder(floor(
? ? ? ? ? ?colour * zoom
?--(sin(x)*64+sin(y)*64)
?
?
?),6*n-1)
?color = mag(color)
?
?pixel(color, {i,j} )
? ? ? ? ? ?
?if Sound then
? ? ? ?
? ? ? ? ? ?
?if color = 0 and time() > Time then
?
? ? ? ? ? ? ? ?y2 = y2 + floor(fully/48)
? ? ? ? ? ? ? ?
?if y2 > fully then
? ? ? ? ? ? ? ? ?y2 = 0
? x2 =x2 + fully/64
? if x2 > fullx then
? x2 = 0
? end if
? ? ? ? ? ? ? ?end if
?
?
?
?
?
?--color = get_pixel({x2,y2})
?--sound(
? ? ? ? ? ? ? ? --floor( white/360*16*
? --scale[floor(remainder(color/ncolors*72,12))+2]*4
? --*power(2,floor(color/ncolors*6))-0)
? --)
?
?sound(
? ? ? ? ? ? ? ? floor( white/360*16*
? scale[floor(remainder(j/fully*6*72,12))+2]*4
? *power(2,floor(j/fully*6))-0)
? )
? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
?
?Time = time()
?
?end if
?
? ? ? ? ? ?end if
? ? ? ? ? ?

?-- see if user wants to quit
?key = get_key()
?if key = ' ' then
? ? return 0
?elsif key = 's' then
? ? ? ? ? ? ?if Sound = 1 then
?Sound = 0
?sound(0)
? else
?Sound = 1
? end if
? ? ? ? ? ?elsif key = 48 then
? ? ? ? ? ? ?mode = 0
? ? ? ? ? ? ?zoom = 1/100
? ? ? ? ? ?elsif key = 49 then
? ? ? ? ? ? ?mode = 1
? ? ? ? ? ? ?zoom = 15
? ? ? ? ? ?elsif key = 50 then
? ? ? ? ? ? ?mode = 2
? ? ? ? ? ? ?zoom = 1/50
? ? ? ? ? ?elsif key = 51 then
? ? ? ? ? ? ?mode = 3
? ? ? ? ? ? ?zoom = 20
? ? ? ? ? ?elsif key = 52 then
? ? ? ? ? ? ?mode = 4
? ? ? ? ? ? ?zoom = 1/100
? ? ? ? ? ?elsif key = 53 then
? ? ? ? ? ? ?mode = 5
? ? ? ? ? ? ?zoom = 1
? ? ? ? ? ? ?speed = 1.005
?elsif key = 54 then
? ? ? ? ? ? ?mode = 6
? ? ? ? ? ? ?zoom = 1
? ? ? ? ? ? ?speed = 1.01
?elsif key = 328 then
? ?zoom = zoom + 1
? ? ? ? ? ?elsif key = 336 then
? ?zoom = zoom - 1
? ? ? ? ? ?elsif key = 13 then
? ?return 1
?end if
end for
end for
zoom = zoom * speed
speed = speed * increase
? ?code = save_screen(0,\"art.bmp\")
? ?if code = 0 then
? ? white = 1.1
? ?end if
?end while
end function

if not select_mode(GRAPHICS_MODE) then
?puts(1, \"couldn't find a good graphics mode\n\")
?abort(1)
end if


while TRUE do
?if poly_pattern() then
exit
?end if
end while
sound(0)
if graphics_mode(-1) then
end if
http://www.rapideuphoria.com/index.html
 


Top