Page 1 of 1
get at point color
Posted: Sat Oct 26, 2024 5:06 pm
by mestnyi
can you confirm that this is a bug in windows?
Code: Select all
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example DPI", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateImage(0, 200, 200, 24, $FFFFFF) And StartDrawing(ImageOutput(0))
; Draw the same figure at different locations by moving the drawing origin
For x = 0 To 120 Step 40
For y = 0 To 120 Step 60
SetOrigin(x, y)
color = Point(x, y)
Debug color
Box(0, 0, 30, 30, $FF0000)
Circle(15, 15, 10, $00FF00)
Circle(15, 15, 5, color)
Next y
Next x
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Re: get at point color
Posted: Sat Oct 26, 2024 5:24 pm
by infratec
If you use SetOrigin() you move the offset.
If you use the original x y, you get out of the image.
Use
to see the cordinates.
If you get 120 for y you are at 240 in reality, which is out of the image.
Re: get at point color
Posted: Sat Oct 26, 2024 5:34 pm
by Bisonte
the help says for POINT() :
For performance reasons there are no bounds checks performed on these coordinates, the specified coordinates must be inside the current drawing area. OutputWidth() and OutputHeight() can be used to verify that. This command is also not affected by calls to ClipOutput().
So there is no check if the coordinates are exist... and if not... error. I said no bug, because the help also said : This command is also not affected by calls to ClipOutput() so I think all is ok.
It makes no sense in your example to write Point(x, y) more 0, 0 or another fixed point, because you are already use a SetOrigin and there you not need the whole Output...
Re: get at point color
Posted: Sat Oct 26, 2024 6:16 pm
by mestnyi
in this example I expected the inner circle to be colored blue, what do you think?
Code: Select all
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example DPI", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateImage(0, 200, 200, 24, $FFFFFF) And StartDrawing(ImageOutput(0))
x = 50
y = 50
size = 30
Box(x, y, size, size, $FF0000)
Circle(x+15, y+15, 10, $00FF00)
color = Point(x+size, y+size)
Debug color
Circle(x+15, y+15, 5, color)
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Re: get at point color
Posted: Sat Oct 26, 2024 6:20 pm
by jacdelad
Point gets a pixel outside your rectangle, because the box ends at X+size-1 (the first of your 30 pixels is on X, then 29 remaining). A box with width 1 draws a single pixel at x,y. Width 2 draws 2 pixel next to each other (x and X+1). The last pixel is always X+width-1. And of course same with y.
Re: get at point color
Posted: Sat Oct 26, 2024 6:26 pm
by mestnyi
jacdelad wrote: Sat Oct 26, 2024 6:20 pm
Point gets a pixel outside your rectangle, because the box ends at X+size-1 (the first of your 30 pixels is on X, then 29 remaining). A box with width 1 draws a single pixel at x,y. Width 2 draws 2 pixel next to each other (x and X+1). The last pixel is always X+width-1. And of course same with y.
why box draw X+size-1?
Re: get at point color
Posted: Sat Oct 26, 2024 6:27 pm
by jacdelad
I said the box ends at X+size-1. The last pixel is there. You get the colour of X+size...but never drew there.
As an example:
draws a box containing just a single pixel at 0,0. You try to get the pixel at 1,1, aka X+size.
Re: get at point color
Posted: Sat Oct 26, 2024 8:47 pm
by Mijikai
A Macro to help debug color:
Code: Select all
Macro DebugColorTriplet(_v_)
Debug RSet(Hex(_v_,#PB_Long),6,"0")
EndMacro
DebugColorTriplet(65280)