1. Re: abs & rad
------=_NextPart_000_0019_01BDD5C5.37FAD160
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Doug Cox wrote:
> While doing some porting from QBasic to Euphoria,
> I came across some commands that I've been unable
> to stick into Euphoria. If anyone could offer a Euphoria
> equivalent to any of these, it would help a lot.
Well hears my answer to abs and rad a another function missing from =
Euphoria. I've included a couple of routines to show they work.=20
=20
include graphics.e
include get.e
constant PI =3D 3.1415927--also handy to know
--
function abs(atom sum)
if sum < 0 then
sum=3D-sum
end if
return sum
end function
--
function rad(atom sum)
sum =3D sum + (180/PI)
return sum
end function
--
procedure circle(atom x,atom y,atom r)
atom j,c
for i=3Dy+r to y-r by -1 do
j=3Dsqrt(abs(r*r-(i-y)*(i-y)))-- abs used hear
draw_line(rand(16),{{x-j,i},{x+j,i}})
end for
end procedure
procedure pixelCircle(atom x,atom y,atom r)
atom j,c
for i=3Dy+r to y-r by -1 do
j=3Dsqrt(abs(r*r-(i-y)*(i-y)))--abs used hear
for l=3Dx-j to x+j do
pixel(rand(16),{l,i})
end for =20
end for
end procedure
--
procedure spikeCircle(atom x,atom y, atom r)
atom a
for angle=3D0 to 360 by 10 do --increace or decrece the 10
a=3Drad(angle)-- rad used hear =20
draw_line(rand(14)+1,{{x,y},{r*cos(a)+x,r*sin(a)+y}})
--pixel(BRIGHT_WHITE,{r*cos(a)+x,r*sin(a)+y}) --swop this line
pixelCircle(r*cos(a)+x,r*sin(a)+y,r/10) --for this line
end for
end procedure =20
--
procedure pattern(atom xco,atom yco,atom radius,atom sides)
sequence x,y
atom k
x=3Drepeat(0,100)
y=3Drepeat(0,100)
for p=3D1 to sides do
x[p]=3Dxco+radius*sin(p*2*PI/sides)-- PI used hear
y[p]=3Dyco+radius*cos(p*2*PI/sides)
end for
for j=3D1 to sides/2 do
for p=3D1 to sides do
k=3Dremainder((p+j),sides)+1
draw_line(rand(14)+1,{{x[p],y[p]},{x[k],y[k]}})
end for
end for
end procedure
--
procedure pause()
puts(1,"\n\nStrike a key")
if wait_key() then end if
clear_screen() =20
end procedure
if graphics_mode(18) then end if
pause()
pattern(320,240,230,20)=20
pause()
for loop =3D 1 to 3 do
for y=3D100 to 400 by 150 do
for x=3D100 to 600 by 150 do=20
if loop =3D 1 then
spikeCircle(x,y,50)=20
elsif loop =3D 2 then
circle(x,y,50)
else
pixelCircle(x,y,50)
end if =20
end for
end for=20
pause()
end for
pause()
if graphics_mode(-1) then end if
Regard
Roy
=20
------=_NextPart_000_0019_01BDD5C5.37FAD160
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type><!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 =
HTML//EN">
<META content=3D'"MSHTML 4.71.1712.3"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2></FONT>Doug Cox wrote:<BR>> While =
doing some=20
porting from QBasic to Euphoria,<BR>> I came across some commands =
that I've=20
been unable<BR>> to stick into Euphoria. If anyone could offer a=20
Euphoria<BR>> equivalent to any of these, it would help a =
lot.<BR><BR></DIV>
<DIV><FONT size=3D2>Well hears my answer to abs and rad a another =
function missing=20
from Euphoria. I've included a couple of routines to show they work.=20
</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>include graphics.e<BR>include=20
get.e</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>constant PI =3D 3.1415927--also =
handy to=20
know</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>--</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>function abs(atom sum)<BR>if sum =
< 0=20
then<BR> sum=3D-sum<BR>end if<BR>return sum<BR>end=20
function</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>--</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>function rad(atom sum)<BR>sum =3D =
sum +=20
(180/PI)<BR>return sum<BR>end function</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>--</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>procedure circle(atom x,atom y,atom =
r)<BR>atom=20
j,c<BR>for i=3Dy+r to y-r by -1 do<BR> =20
j=3Dsqrt(abs(r*r-(i-y)*(i-y)))-- abs used hear<BR> =20
draw_line(rand(16),{{x-j,i},{x+j,i}})<BR>end for<BR>end=20
procedure</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>procedure pixelCircle(atom x,atom =
y,atom=20
r)<BR>atom j,c<BR>for i=3Dy+r to y-r by -1 do<BR> =20
j=3Dsqrt(abs(r*r-(i-y)*(i-y)))--abs used hear<BR> for =
l=3Dx-j to=20
x+j do<BR> =20
pixel(rand(16),{l,i})<BR> end for =
<BR>end=20
for<BR>end procedure</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>--</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>procedure spikeCircle(atom x,atom y, =
atom=20
r)<BR> atom a<BR> for angle=3D0 to =
360 by 10=20
do --increace or decrece the =
a=3Drad(angle)-- rad used hear =20
<BR> =20
p; =20
--pixel(BRIGHT_WHITE,{r*cos(a)+x,r*sin(a)+y}) --swop this=20
line<BR> =20
p; =20
--for this line<BR> end for<BR>end=20
procedure </FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>--</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>procedure pattern(atom xco,atom =
yco,atom=20
radius,atom sides)<BR>sequence x,y<BR>atom=20
k<BR>x=3Drepeat(0,100)<BR>y=3Drepeat(0,100)<BR>for p=3D1 to sides=20
do<BR> x[p]=3Dxco+radius*sin(p*2*PI/sides)-- PI used=20
hear<BR> y[p]=3Dyco+radius*cos(p*2*PI/sides)<BR>end =
for<BR>for=20
j=3D1 to sides/2 do<BR> for p=3D1 to sides=20
;=20
draw_line(rand(14)+1,{{x[p],y[p]},{x[k],y[k]}})<BR> =
end=20
for<BR>end for<BR>end procedure</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>--</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>procedure =
pause()<BR>puts(1,"\n\nStrike a=20
key")<BR>if wait_key() then end =
if<BR>clear_screen() =20
<BR>end procedure</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>if graphics_mode(18) then end=20
if<BR>pause()</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2>pattern(320,240,230,20) =
<BR>pause()<BR>for loop=20
=3D 1 to 3 do<BR> for y=3D100 to 400 by 150=20
do<BR> for x=3D100 to 600 by =
150 do=20
<BR> =
if loop =3D=20
1=20
; =20
spikeCircle(x,y,50)=20
sp; =20
elsif loop =3D 2=20
=20
bsp; =20
end if =
<BR> end =
for<BR> end=20
for <BR> pause()<BR>end for<BR>pause()<BR>if =
graphics_mode(-1) then=20
end if</FONT> </DIV>
<DIV><FONT color=3D#000000 size=3D2><BR>Regard</FONT> </DIV>
<DIV><FONT color=3D#000000 =
------=_NextPart_000_0019_01BDD5C5.37FAD160--