A simple graphics rectangle? My coordinates are wrong - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: A simple graphics rectangle? My coordinates are wrong (/thread-6338.html) |
A simple graphics rectangle? My coordinates are wrong - StephenG1CMZ - 06-01-2016 11:16 PM This should be a simple rectangle inside a rectangle - but I am not seeing the border I expect. It seems almost like the inner x,y coordinates are being seen as lengths rather than absolute coordinates. Where am I going wrong? (Android version) Code:
RE: A simple graphics rectangle? My coordinates are wrong - cyrille de brébisson - 06-02-2016 05:28 AM Hello, RECT_P uses the top left and bottom right (included) coordinates. Text writing is always strange because characters do not always start on the provided starting point. They are very often shifted by a number of pixels. Why are you using so many alpha channel values? are you truly trying to have semi transparent colors in your test program? Cyrille RE: A simple graphics rectangle? My coordinates are wrong - StephenG1CMZ - 06-02-2016 06:42 AM (06-02-2016 05:28 AM)cyrille de brébisson Wrote: Hello, No, all I wanted was two different colours - I will add in a list of more sensible values for the user to choose later. But first, I want to understand why the final inner rectangle obscures the border - not because of transparency, but the x and y coordinates are not producing what I expected. If I understand it, the coordinate (255+border,YLEN+border) should not overlap the outer border at (255+2border,YLEN+2border) and overwrite the final border. I think I need to find a bug in my code or understanding. RE: A simple graphics rectangle? My coordinates are wrong - Claudio L. - 06-03-2016 05:46 PM (06-02-2016 05:28 AM)cyrille de brébisson Wrote: RECT_P uses the top left and bottom right (included) coordinates. (06-02-2016 06:42 AM)StephenG1CMZ Wrote: If I understand it, the coordinate (255+border,YLEN+border) should not overlap the outer border at (255+2border,YLEN+2border) and overwrite the final border. I think I need to find a bug in my code or understanding. I think your problem is in the definition above. It draws up to and including those coordinates. So you go (0,0) to (255+2*BWIDTH,BWIDTH), then (0,BWIDTH) to (BWIDTH,YLEN+BWIDTH) for example. The segment exactly at (0,BWIDTH) to (BWIDTH,BWIDTH) is included in both rectangles, therefore it's overlapping. If you want your width to be 255 pixels and have BWIDTH border each side, you'll go: from 0 to BWIDTH-1, then your main area goes from BWIDTH to 255+BWIDTH-1, and the final border from 255+BWIDTH to 255+2*BWIDTH-1. RE: A simple graphics rectangle? My coordinates are wrong - StephenG1CMZ - 06-05-2016 08:35 AM Thanks for your insights guys... This version seems much clearer. One known bug for me to look into in this code if it becomes necessary: If border width is changed to 0 a border still appears. Code:
RE: A simple graphics rectangle? My coordinates are wrong - Arno K - 06-05-2016 12:15 PM Hello Stephen, the problem must be computation of data in BORDERU, if BWIDTH is 0 then BORDERU(4) is -1, I don't know why this works at all. But after I tried without these -1 parts the Programm still draws a line. So the conclusion is that rect_p cannot draw rectangles of size 0. Arno RE: A simple graphics rectangle? My coordinates are wrong - Arno K - 06-05-2016 08:46 PM Well, concerning my last answer I now wrote 2 simple lines of code Code: RECT_P(); Arno |