Mintoris Forum

Author Topic: Buttons  (Read 5955 times)

George

  • Full Member
  • ***
  • Posts: 22
Buttons
« on: Feb 07, 2012, 02:06 AM »
I had used a crude button on my first program then evolved to a better button in subsequent versions. I just looked at Bill K's button implementation and was wondering what the overhead was for translating the Color command from a string to the RGB. I like the way he did that, but I was afraid it would slow things down. Is this true?

I love BK's stuff. My own buttons don't seem as responsive as I'd like (try LunarLander and see what I mean). I was worried about the overhead of using something like BK's routines in future programs. Comments?

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Buttons
« Reply #1 on: Feb 07, 2012, 05:27 AM »
I think that BillK's button subs could be re-written to use one array for button text and another array for the numeric values.  On the other hand it's not a ton of string conversions so it's probably fine.

-Chuck

George

  • Full Member
  • ***
  • Posts: 22
Re: Buttons
« Reply #2 on: Feb 07, 2012, 10:31 PM »
Makes sense.
I was playing around with drawing squares for buttons and discovered that I had totally misunderstood what the parameters for Rect was. I had thought it was the upper corner X1,Y1 and the lower corner X2,X2. When I tried to mesh a circle and a square it was all off. Could you explain what the parameter rational is for those of us not familiar with graphics stuff?
   -George

(P.S. Glad you upped the Attachments.)

George

  • Full Member
  • ***
  • Posts: 22
Re: Buttons
« Reply #3 on: Feb 07, 2012, 10:34 PM »
CORRECTION: "…upper corner X1, Y1 and the lower corner X2, Y2."

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Buttons
« Reply #4 on: Feb 08, 2012, 08:14 AM »
When I added the graphics mode I decided to lock the screen in the portrait orientation.  This pretty much had to be done or the x and y axis would switch randomly as the user reorientated the device.  In the portrait orientation all the underlying Java graphics commands use the upper left corner of the screen as 0,0 so that is what Basic does.

Hope this helps.

-Chuck

George

  • Full Member
  • ***
  • Posts: 22
Re: Buttons
« Reply #5 on: Feb 08, 2012, 08:17 PM »
Chuck,
What I meant was the Rect command parameters are LEFT, TOP, RIGHT, BOTTOM. I don't know what that means as relates to a Cartesian system.
<Pause>
After I wrote the above I stopped to go out on the patio to have a cigar with my wife. While there she asked me what I was working on and I explained my confusion. Let me say here that this is the same woman who has asked me this question for over thirty years and patiently listened to my explanations. The same one who, with no previous knowledge except my explanations of one theory or another decided to take her Novice then Technician class tests in amateur radio (in the days of morse code requirements) and passed both. She passed the code because she learned it helping me learn. So for this latest problem, I explained how the coordinate system worked and what the command syntax was. She thought for a minute, then explained how Rect was similar to Circle and that the Left , Top, Right, and Bottom appeared to be nothing more than displacements from X&Y: the equivalent of radius of a circle, but for a square. She wrote:

   X=200
   Y=200
   r=50
   Rect X-r,Y-r,X+r,Y+r
   Circle X,Y,r

…and said, "Try that."

What do you know‼ I got a circle surrounded by a square.

Now if she'd just smoke her own cigars ….


(P.S. I made her buy her own copy of Mintoris Basic‼ I'll ask her next time before I clutter up your forum.)

 




Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Buttons
« Reply #6 on: Feb 08, 2012, 08:59 PM »
I knew you would get it figured out.  I think that the problem is that the coordinate system of the Android screen is different than the Cartesian Coordinate system in that the Y axis' sign is reversed.  That is Y goes positive as it goes down the screen.

-Chuck

barryem

  • Full Member
  • ***
  • Posts: 17
Re: Buttons
« Reply #7 on: Jul 04, 2016, 07:48 PM »
I realize I'm replying to this in what might seem to be late for some of you kids but to an old fogey 4 years is nothing. :)

A lot of the books on graphics in Basic (and other languages) in the 80s also treated Y as increasing toward the bottom of the screen.  Some also set the orgin at the upper left or lower left corner instead of the center.  I don't remember which method was more common.

Barry