A simple graphics rectangle? My coordinates are wrong
|
06-01-2016, 11:16 PM
Post: #1
|
|||
|
|||
A simple graphics rectangle? My coordinates are wrong
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:
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
06-02-2016, 05:28 AM
Post: #2
|
|||
|
|||
RE: A simple graphics rectangle? My coordinates are wrong
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 Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
06-02-2016, 06:42 AM
(This post was last modified: 06-02-2016 06:55 AM by StephenG1CMZ.)
Post: #3
|
|||
|
|||
RE: A simple graphics rectangle? My coordinates are wrong
(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. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
06-03-2016, 05:46 PM
Post: #4
|
|||
|
|||
RE: A simple graphics rectangle? My coordinates are wrong
(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. |
|||
06-05-2016, 08:35 AM
(This post was last modified: 06-05-2016 08:37 AM by StephenG1CMZ.)
Post: #5
|
|||
|
|||
RE: A simple graphics rectangle? My coordinates are wrong
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:
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
06-05-2016, 12:15 PM
Post: #6
|
|||
|
|||
RE: A simple graphics rectangle? My coordinates are wrong
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 |
|||
06-05-2016, 08:46 PM
Post: #7
|
|||
|
|||
RE: A simple graphics rectangle? My coordinates are wrong
Well,
concerning my last answer I now wrote 2 simple lines of code Code: RECT_P(); Arno |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)