Precondition: GFX_ALPHA_PRIMITIVES is set, in ScreenRes statement.
A color (ULong) 32 bit, used with Alpha other than 255/&hFF as border-color is used.
The result of which is, coloring of the entire user-screen, not respecting the set border.
' Paint-Leak_ex1.bas -- (c) 2019-04-06, MrSwiss
'
' compile: -s gui
'
Const As UShort wid = 1024, hei = 768, cd = 32, pg = 2, sflg = 64
' ===== Start-Main =====
ScreenRes(wid, hei, cd, pg, sflg) ' sflg = GFX_ALPHA_PRIMITIVES
Width wid \ 8, hei \ 16
Color(&hFF000000, &hFFFFFFFF) : Cls ' black (fg) on white (bg)
Line (100, 100)-(wid-101, hei-101), &hFFFF0000, B ' works correctly, fully opaque
Paint(101, 101), &h3fFFFF00, &hFFFF0000 ' fill color can be anything!
Flip
Sleep : Cls
Line (100, 100)-(wid-101, hei-101), &hBFFF0000, B ' 25% transparent border = LEAK!!!
Paint(101, 101), &h3fFFFF00, Point(100, 100) ' adapted as per counting_pine's advice
Flip
Sleep
As discussed with counting_pine at: https://www.freebasic.net/forum/viewtopic.php?f=3&t=27537
So as concluded on the forum, the problem is actually line overdraw with the box - the corners are drawn twice, changing their value - and the Point chosen for the border colour is on the corner. If e.g.
Point(100,101)is chosen, the fill stops at the border colour as expected.It's by far NOT as simple, as further testing revealed: the simplistic method from fxm, works only with rectangular shapes (90 degree angles), whenever different shapes are drawn using LINE, there will (with high probability) a overlap of pixels happen, which will be causing a leak by a following PAINT statement. One single Pixel is enough to do it; e.g. closing a ellipse / star / polygon e.t.c..
This fact should at least be documented, on the LINE doc-page, of the FB-reference.
The only truely working workaroud, at this point in time is, to set the given border-color to 'fully opaque', by something like:
Since a fix for this behaviour is unlikely, but at least the documentation has been updated, to explain the noted behaviour, with LINE / CIRCLE in conjunction with PAINT, this ticket may be declared as: "closed".
See changed pages in documentation: https://www.freebasic.net/forum/viewtopic.php?f=3&p=259899#p259899
Thank you MrSwiss. Issue resolved through documentation.