|
Post by Rod on Jul 24, 2020 3:03:06 GMT -5
I think it is a bit more complex than that. 800 gives us 800 pixels. The border is two pixels, one either side. So 800-2 = 798 available pixels 798/2 = 399 center. So we have a drawing area of 798 pixels which have been numbered 0-797
WindowWidth = 800 WindowHeight = 600
nomainwin
button #w.b "Quit",[quit],UL,360,560
graphicbox #w.g, 0,0,800,600 open "" for window_popup as #w
#w.g "down ; color red ; set 0 0 ; set 797 0 ; set 797 597 ;set 0 597" #w.g "home ; posxy x y" #w.g "set 399 299 ; circle 399 ; circle 299"
#w.g "place 400 350 ;\";x;" ";y
wait
[quit] close #w end
|
|
|
Post by Rod on Jul 24, 2020 10:18:51 GMT -5
Stylebits recovers the 2 pixels as you say and moves the center 1 pixel giving us 400,300 as the center and drawing pixels 0-799 instead of 0-797. Note that "0" seems to move but these are just labels addressing the available pixels, the first available will always be "0"
WindowWidth = 800 WindowHeight = 600
nomainwin stylebits #w, 0,_WS_border,0,0 stylebits #w.g, 0,_WS_border,0,0 'here you "win" 2 pixels
button #w.b "Quit",[quit],UL,360,560
graphicbox #w.g, 0,0,800,600 open "" for window_popup as #w
#w.g "down ; fill black ; color red ; set 0 0 ; set 799 0 ; set 799 599 ;set 0 599" #w.g "set 799 0 ; set 799 599" #w.g "home ; posxy x y" #w.g "set 400 300 ; circle 400 ; circle 300"
#w.g "place 400 350 ;\";x;" ";y
wait
[quit] close #w end
|
|
|
Post by Carl Gundel on Jul 24, 2020 11:49:26 GMT -5
Stylebits recovers the 2 pixels as you say and moves the center 1 pixel giving us 400,300 as the center and drawing pixels 0-799 instead of 0-797. Note that "0" seems to move but these are just labels addressing the available pixels, the first available will always be "0" Stylebits will be deemphasized with LB5. So what we should do is agree about exactly how we want these things to work going forward.
|
|
|
Post by Carl Gundel on Jul 24, 2020 12:54:06 GMT -5
Stylebits recovers the 2 pixels as you say and moves the center 1 pixel giving us 400,300 as the center and drawing pixels 0-799 instead of 0-797. Note that "0" seems to move but these are just labels addressing the available pixels, the first available will always be "0" Stylebits will be deemphasized with LB5. So what we should do is agree about exactly how we want these things to work going forward. In my thinking a graphicbox widget should be exactly the number of pixels wide as specified including the border. If we are interested in a borderless graphicbox I can work on supporting that also. So in that case a 200x300 graphicbox would give you exactly that many pixels wide and high to draw on. As for whether the origin of the window starts at 1,1 or 0,0 I'll have to chew on that. Perhaps this might be an opportunity to introduce a generalized translation feature in there?
|
|
|
Post by Chris Iverson on Jul 24, 2020 13:18:37 GMT -5
I've always imagined grids of pixels as graphs, and graphs always start at 0,0.
Every windowing system I've worked with has always used 0,0 as the origin, and I think making that different for just one programming language would be a lot of hassle. Especially since you'll have to have LB constantly doing off-by-one translations when working with the abstracted GUI layers. (And I don't mean that in general for anyone working with APIs, although it would apply there; I mean that specifically for you, Carl, in that any code you write to do any GUI work in LB's runtime will have to compensate for the fact LB and the underlying system are using different enumeration conventions.)
That's just my own thoughts, though.
|
|
|
Post by Rod on Jul 24, 2020 13:41:20 GMT -5
Yes I am perfectly happy with 0,0 as the first visible pixel. To be honest the border has never bothered me so loss of stylebits is no big deal.
For beginners asking for 800 pixels they might expect to get 800 pixels, but currently we get 0-797 drawable pixels. Now the loss of two border pixels is easy to explain and so too the 0-797 range. While it is actually what we have now perhaps auto adding 2 to the requested size and delivering 0-799 drawable pixels will give what folks expect.
Will it spoil old code? well mostly the drawing will be off screen and not visible and probably unnoticed.
The second part to this is how to size a Window to contain and show, in its entirety, a graphicbox. But perhaps the advice there is to use a graphics window or a popup/graphicbox window and just say that graphicboxes in normal windows need space, dont expect to see 800x600 in 800x600 that is a naive coding.
|
|
|
Post by gidiom2 on Jul 24, 2020 15:09:51 GMT -5
I don't see a problem with incorrect pixel points on a borderless graphicbox if the window is larger than the graphicbox. Maybe I'm missing the point of the discussion (very likely! ) The code below sets a visible pixel at each corner of a 800x600 graphicbox using points 0 to 799 and 0 to 599. If you can't see the pixels, make sure you read the comments. 'Draw a borderless graphicbox 800px X 600px inside a slightly larger popup window. 'Fill the graphicbox lightgray to show its existence. 'set a pixel at each corner of the graphicbox (may ned a magnifying glass too see a single red pixel!) 'Graphics drawing has to use the 'X' range 0 to 799 (800px) and 'Y' range 0 to 599 (600px) 'So unless I'm missing the point, there is no problem ?
'popup window bigger than graphicbox WindowWidth = 820 WindowHeight = 620
nomainwin stylebits #w.g, 0,_WS_BORDER,0,0 button #w.b "Quit",[quit],UL,360,560
graphicbox #w.g, 0,0,800,600 open "" for window_popup as #w
#w.g "down; fill lightgray" #w.g "size 1;color red ; set 0 0 ; set 799 0 ; set 799 599 ;set 0 599"
wait
[quit] close #w end
|
|
|
Post by Gordon Rahman on Jul 24, 2020 15:14:35 GMT -5
I'm digging up old listings that had an problem with a white line at the bottom (underside) of a sprite. It's a pity that I changed everything already to the better, so now I can't find those listings. I vaguely remember that it had to do something with sprites whom building needed an odd number of lines? and that it would then be good to have 1,1 as starting point?
But now I just would only advice to mention it in the helpfile, what to expect from the drawable size of a graphic window or area.
Gordon
|
|
|
Post by Rod on Jul 25, 2020 2:46:26 GMT -5
Yeh, the point of the discussion is that you don’t get 0-799 if you use the default graphicbox which has a border. Sprite masks must be a mirror image of the sprite so odd height .bmps just won’t do, they have to be even height .bmps
|
|
|
Post by gidiom2 on Jul 25, 2020 4:37:25 GMT -5
Yeh, the point of the discussion is that you don’t get 0-799 if you use the default graphicbox which has a border. Sprite masks must be a mirror image of the sprite so odd height .bmps just won’t do, they have to be even height .bmps OK, what seems to be the simple answer is for Carl to make the default graphicbox have no border. A graphicbox does not standalone, it goes inside another window so a border is not needed. That would give full access to all pixels. Is that correct? I would have thought a simple change to LB4, but what do I know!
|
|
|
Post by Rod on Jul 25, 2020 6:28:01 GMT -5
I think we all agree you should get 0-799 when you ask for 800 pixels. So stylebits will not be available in LB5 , Carl is suggesting we can have an optional border. I would say he should add two pixels to the width if we request a border and leave us always having 0-799 pixels to draw in either case.
I think the border can be important in a featureless gui where it defines the viewing area. Having a bordered box two pixels wider is in my opinion much more logical than inexplicably loosing pixels.
|
|
|
Post by Carl Gundel on Jul 25, 2020 8:55:41 GMT -5
I think we all agree you should get 0-799 when you ask for 800 pixels. So stylebits will not be available in LB5 , Carl is suggesting we can have an optional border. I would say he should add two pixels to the width if we request a border and leave us always having 0-799 pixels to draw in either case. I think the border can be important in a featureless gui where it defines the viewing area. Having a bordered box two pixels wider is in my opinion much more logical than inexplicably loosing pixels. 800 wide means 800 wide for the widget. The border is not going to be optional, it will be there by default. This means that unless you turn off the border the range will be 0-797. Change my mind.
|
|
|
Post by Gordon Rahman on Jul 25, 2020 9:59:12 GMT -5
This is the task I (wanted to ) asked the "beginners".
WindowWidth = 800 WindowHeight = 600 nomainwin
button #w.b "Quit",[quit],UL,320,560
stylebits #w, 0,_WS_border,0,0 graphicbox #w.g, 0,0,800,600 open "" for window_popup as #w #w.g "when characterInput [LorR]" #w.g "down" #w.g "color black; size 3; place 0 0; box 798 598" #w.g "down; size 3; setfocus" Nx = 398 :Ny = 3 Ex = 794 :Ey = 298 Sx = 398 :Sy = 594 Wx = 3 :Wy = 298
[LorR] key$ = Inkey$ if len(key$)= 2 then arrow = asc(right$(key$,1)) if arrow = 39 then goto [rechts] if arrow = 37 then goto [links] end if wait
[rechts] #w.g "color white" #w.g "line ";Nx;" ";Ny;" ";Sx;" ";Sy #w.g "line ";Ex;" ";Ey;" ";Wx;" ";Wy Nx = Nx + 1: Sx = Sx - 1 Ey = Ey + 1: Wy = Wy - 1 #w.g "color black" #w.g "line ";Nx;" ";Ny;" ";Sx;" ";Sy #w.g "line ";Ex;" ";Ey;" ";Wx;" ";Wy wait
[links] #w.g "color white" #w.g "line ";Nx;" ";Ny;" ";Sx;" ";Sy #w.g "line ";Ex;" ";Ey;" ";Wx;" ";Wy Nx = Nx - 1: Sx = Sx + 1 Ey = Ey - 1: Wy = Wy + 1 #w.g "color black" #w.g "line ";Nx;" ";Ny;" ";Sx;" ";Sy #w.g "line ";Ex;" ";Ey;" ";Wx;" ";Wy wait
wait [quit] close #w end
I had a hard time explaining how to find out the numbers of NEWS
Gordon
|
|
|
Post by Rod on Jul 25, 2020 10:19:01 GMT -5
Well beginners probably think that the 800 refers to pixels not the widget size. In case we don't get an option to remove the border how about a help file example that requests an 802 wide widget. That starts to tell beginners the widget size is not the drawing area size. Then show a full 800 wide drawing using 0-799. That tells beginners the pixels are zero indexed. Its just about making folks aware of the differences rather than the 800, 800 code we often see that never actually shows what it should.
nomainwin
'to obtain 800 visible pixels we need 802 pixels to accommodate the 2 border pixels 'the 800 visible pixels are numbered 0-799 WindowWidth = 802 WindowHeight = 602
button #w.b "Quit",[quit],UL,360,560 graphicbox #w.g, 0,0,802,602 open "" for window_popup as #w
'color each corner pixel of the graphicbox #w.g "down ; color red ; set 0 0 ; set 799 0 ; set 799 599 ;set 0 599"
'find the center of the graphicbox #w.g "home ; posxy x y"
'draw centered circles touching each edge of the graphicbox #w.g "set 400 300 ; circle 400 ; circle 300"
'tell us what the center is #w.g "place 400 350 ;\";x;" ";y wait
[quit] close #w end
|
|
|
Post by Gordon Rahman on Jul 25, 2020 10:33:48 GMT -5
I agree with mentioning it in the help-file. We fixed the problem by drawing the border extra. But !!!! Drawing a box 0,0,800,600 doesn't showed a complete border.
WindowWidth = 800 WindowHeight = 600 nomainwin
button #w.b "Quit",[quit],UL,320,560
stylebits #w, 0,_WS_border,0,0 graphicbox #w.g, 0,0,800,600 open "" for window_popup as #w #w.g "when characterInput [LorR]" #w.g "down" #w.g "color black; size 3; place 0 0; box 798 598" #w.g "down; size 3; setfocus" Nx = 400 :Ny = 3 Ex = 800 :Ey = 300 Sx = 400 :Sy = 600 Wx = 3 :Wy = 300
[LorR] key$ = Inkey$ if len(key$)= 2 then arrow = asc(right$(key$,1)) if arrow = 39 then goto [rechts] if arrow = 37 then goto [links] end if wait
[rechts] #w.g "color white" #w.g "line ";Nx;" ";Ny;" ";Sx;" ";Sy #w.g "line ";Ex;" ";Ey;" ";Wx;" ";Wy Nx = Nx + 1: Sx = Sx - 1 Ey = Ey + 1: Wy = Wy - 1 #w.g "color black" #w.g "line ";Nx;" ";Ny;" ";Sx;" ";Sy #w.g "line ";Ex;" ";Ey;" ";Wx;" ";Wy #w.g "color black; size 3; place 0 0; box 798 598" wait
[links] #w.g "color white" #w.g "line ";Nx;" ";Ny;" ";Sx;" ";Sy #w.g "line ";Ex;" ";Ey;" ";Wx;" ";Wy Nx = Nx - 1: Sx = Sx + 1 Ey = Ey - 1: Wy = Wy + 1 #w.g "color black" #w.g "line ";Nx;" ";Ny;" ";Sx;" ";Sy #w.g "line ";Ex;" ";Ey;" ";Wx;" ";Wy #w.g "color black; size 3; place 0 0; box 798 598" wait
wait [quit] close #w end
|
|