#### johnno56

• Guest
##### Re: I've asked this before... but...
« Reply #15 on: April 20, 2015 »
Peter,

Cool. also VERY fast. Am I correct in assuming that _drawcircle is another way of writing proc drawcircle ?

Many thanks.

J

#### Peter

• Guest
##### Re: I've asked this before... but...
« Reply #16 on: April 20, 2015 »
Quote
_drawcircle is another way of writing proc drawcircle ?
accurate!

here*s another learn-object.
Code: [Select]
`set window 16,16,640,480set redraw offradiansx1#=200.0; y1#=200.0; a#while keydown(27)=0set color 0,0,0clsfor j=2 to 100    i# = float(j)    x2# = x1 + cos(i+a)*i*10.0    y2# = y1 + sin(i+a)*i*10.0    set color 200, 255, 200    draw rect 80+int(x2),int(y2),j,jnexta = a+1.0rem another fine thing is: a = a+0.01if a >=360.0 then a = -aredrawwait 10wend `

#### B+

• Full Member
• Posts: 215
##### Re: I've asked this before... but...
« Reply #17 on: April 20, 2015 »
Hi Peter,

Yep! My circle procedure very slow! Decided to have a cup of coffee while computer was drawing my red circles (which I now have under my eyes for staying up so late). Out of coffee, so I planted some bean trees, grew them, manufactured the coffee, ground it, brewed it, ...ah coffee! and the red circle program was still drawing!

B+

« Last Edit: April 20, 2015 by B+ »
B+

#### B+

• Full Member
• Posts: 215
##### Re: I've asked this before... but...
« Reply #18 on: April 20, 2015 »
WOW!

set redraw off
....draw the stuff then
redraw

what a difference in time!

For the Red Circles program, I didn't have time to take a single sip of coffee before the thing pops up whole on the screen!

I am looking over the circle drawing algorithm's and see the whole program draws the circle not just the circle procedure.

I also notice this:
Code: [Select]
`procedure drawcircle(xc#,yc#,x#,y#) draw pixel int(xc + x), int(yc + y) draw pixel int(xc - x), int(yc + y) draw pixel int(xc + x), int(yc - y) draw pixel int(xc - x), int(yc - y) draw pixel int(xc + y), int(yc + x) draw pixel int(xc - y), int(yc + x) draw pixel int(xc + y), int(yc - x) draw pixel int(xc - y), int(yc - x)endproc`How come you don't need to write  xc#,yc#, x#,y# in the procedure?
Ah, also in Peter's "another learn-object" the a# defined at top and then used with just a

***   "Foolish consistency is the hobgoblin of little minds?"  ***

J, is this what you were getting at, about knowing when to use integer and when a float?

I will guess and then test this idea, once you "define" a float, you don't have to use the # to remind the compiler, so therefore a\$ and a# and a can't coexist in same program?

B+
B+

#### aurel

• Jr. Member
• Posts: 61
##### Re: I've asked this before... but...
« Reply #19 on: April 20, 2015 »
Quote
so therefore a\$ and a# and a can't coexist in same program
heh..it looks that you have serious problem with def var
and who and where use same name for different variable type ?

#### B+

• Full Member
• Posts: 215
##### Re: I've asked this before... but...
« Reply #20 on: April 20, 2015 »
Quote
so therefore a\$ and a# and a can't coexist in same program
heh..it looks that you have serious problem with def var
and who and where use same name for different variable type ?

x and y all the time, to make integer or to make float?

that is the question.

B+
B+

#### johnno56

• Guest
##### Re: I've asked this before... but...
« Reply #21 on: April 20, 2015 »
B+,

Quote
J, is this what you were getting at, about knowing when to use integer and when a float?

Yep. I get soooo confused at times, my brain turns to mush... *sigh*

Interesting point about defining a# and a\$. I had not considered that before.

J

#### Peter

• Guest
##### Re: I've asked this before... but...
« Reply #22 on: April 21, 2015 »
float exercise no. 2:
Code: [Select]
`set window 32,32,640,480set redraw offradiansa#while keydown(27)=0set color 0,0,0clsset color 255,255,255_DrawCube 300.0, 100.0, 80.0, a_DrawCube 300.0, 300.0, 90.0,-aset color 255,200,0_DrawCube  20.0,  20.0, 20.0, a_DrawCube 600.0, 460.0, 20.0,-aa = a+0.1if a>=360.0 then a=-aredraw wait 80wendprocedure DrawCube(x#, y#, s#, a#)x1# = xy1# = yx2# = x1+cos(a)*sy2# = y1+sin(a)*sx3# = x2+cos(a+90.0)*sy3# = y2+sin(a+90.0)*sx4# = x1+cos(a+90.0)*sy4# = y1+sin(a+90.0)*sdraw line int(x1), int(y1), int(x2), int(y2)draw line int(x2), int(y2), int(x3), int(y3)draw line int(x3), int(y3), int(x4), int(y4)draw line int(x4), int(y4), int(x1), int(y1)draw line int(x1+s), int(y1), int(x2+s), int(y2)draw line int(x2+s), int(y2), int(x3+s), int(y3)draw line int(x3+s), int(y3), int(x4+s), int(y4)draw line int(x4+s), int(y4), int(x1+s), int(y1) draw line int(x1), int(y1), int(x1+s), int(y1)draw line int(x2), int(y2), int(x2+s), int(y2)draw line int(x3), int(y3), int(x3+s), int(y3)draw line int(x4), int(y4), int(x4+s), int(y4)endproc`

#### B+

• Full Member
• Posts: 215
##### Re: I've asked this before... but...
« Reply #23 on: April 21, 2015 »
WOW!

set redraw off
....draw the stuff then
redraw

what a difference in time!

For the Red Circles program, I didn't have time to take a single sip of coffee before the thing pops up whole on the screen!

I am looking over the circle drawing algorithm's and see the whole program draws the circle not just the circle procedure.

I also notice this:
Code: [Select]
`procedure drawcircle(xc#,yc#,x#,y#) draw pixel int(xc + x), int(yc + y) draw pixel int(xc - x), int(yc + y) draw pixel int(xc + x), int(yc - y) draw pixel int(xc - x), int(yc - y) draw pixel int(xc + y), int(yc + x) draw pixel int(xc - y), int(yc + x) draw pixel int(xc + y), int(yc - x) draw pixel int(xc - y), int(yc - x)endproc`How come you don't need to write  xc#,yc#, x#,y# in the procedure?
Ah, also in Peter's "another learn-object" the a# defined at top and then used with just a

***   "Foolish consistency is the hobgoblin of little minds?"  ***

J, is this what you were getting at, about knowing when to use integer and when a float?

I will guess and then test this idea, once you "define" a float, you don't have to use the # to remind the compiler, so therefore a\$ and a# and a can't coexist in same program?

B+

OK I did some tests here is a cool result!
Code: [Select]
`rem Circle test v1 revised 2015-04-21 B+rem here we test idea that you only have to tell the compiler once your variable is a floatrem modified circle procedure so color can be set by caller program of circle procedurerem so more color this time around testing a general circle proc also .1 better! refinementsq=520 set window 0,0,sq,sqset redraw offrem originx0 = int(sq/2)y0 = int(sq/2)for i=0 to 255 set color 255-i,255-i,255-i _circle x0,y0,inext redrawwait keydownendprocedure circle(x,y,r)i#=0.0do xpos = int(sin(i) * float(r)) ypos = int(cos(i) * float(r)) draw pixel xpos+x,ypos+y i = i + 0.1until i >= 360.0endproc`
B+

#### Peter

• Guest
##### Re: I've asked this before... but...
« Reply #24 on: April 21, 2015 »
great   B+,
Code: [Select]
`rem Peter was here.set window 0,0,520,520set redraw offsq = 520x0 = sq/2y0 = sq/2for i=0 to 255      set color (255-i)*int(0.5),255-i,255-i   _circle x0,y0,i   _circle x0-i,y0+i,i   _circle x0-i,y0-i,i   _circle x0+i,y0+i,i   _circle x0+i,y0-i,inext redrawwait keydownendprocedure circle(x,y,r)i#doxpos = int(sin(i) * float(r))ypos = int(cos(i) * float(r))draw pixel xpos+x,ypos+yi = i + 0.1until i >= 360.0endproc`

#### johnno56

• Guest
##### Re: I've asked this before... but...
« Reply #25 on: April 21, 2015 »
Very nice examples, indeed. Well done.

J

#### B+

• Full Member
• Posts: 215
##### Re: I've asked this before... but...
« Reply #26 on: April 22, 2015 »
Yes Johnno, they look # but are you any clearer on float?

My theory is once you tell the compiler: i#
all future references to i are assumed float by it.

i# (first time), therefore i am float,

B+
B+

#### johnno56

• Guest
##### Re: I've asked this before... but...
« Reply #27 on: April 22, 2015 »
B+,

Yes. Much clearer, thanks.

J

#### B+

• Full Member
• Posts: 215
##### Floats!
« Reply #28 on: May 12, 2015 »
That was only half the story with floats and integers!

The other half is that your literal numbers also have to be 0.xxxx or xxx.0 for floats!
Code: [Select]
`x#=1.11rem a#=x#+1 rem = error? yepb#=x#+1.0 rem = OK? yeprem c#=x#+.01 rem = error? yepd#=x#+0.01 rem = OK? yep`
Good golly Miss Molly, no wonder one's brain turns to mush!

that and coffee (which floats my bloat),

B+
« Last Edit: May 12, 2015 by B+ »
B+

#### johnno56

• Guest
##### Re: I've asked this before... but...
« Reply #29 on: May 12, 2015 »
Thanks for the info B+.  I am slowly figuring out the float thingy.  I have particular difficulty when both float and integer are combined in a calculation.  I apologise for not being as quick as others, when it comes to floating point, I have not had to deal with them in the past.  *sigh*

J