Fred, please CanvasGadget() and surface with alpha support
Fred, please CanvasGadget() and surface with alpha support
hello Fred it seems to me that it would be time to have with CanvasGadget the Point(x,y) function
which could return us a color in RGBA
best regard
which could return us a color in RGBA
best regard
Last edited by kernadec on Thu Mar 16, 2023 7:37 am, edited 1 time in total.
Re: CanvasGadget Function Point(x,y) in RGBA
The canvas gadget is a 24 bit image and has no alpha channel itself.
Therefor Point() returns only 24 bit.
If you use a 32 bit image, Point also returns 32 bit.
Therefor Point() returns only 24 bit.
If you use a 32 bit image, Point also returns 32 bit.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: CanvasGadget Function Point(x,y) in RGBA
Hi, Stargate ok thank you,
but the canvas is a drawing surface where you can use transparency but you can't recover color from fades to transparency
so why stay in 24 bits i think it's time now that the machines are more advanced with giga of ram so why not CanvasGadget
best regard
but the canvas is a drawing surface where you can use transparency but you can't recover color from fades to transparency
so why stay in 24 bits i think it's time now that the machines are more advanced with giga of ram so why not CanvasGadget
best regard
Re: CanvasGadget Function Point(x,y) in RGBA
Since you are in favor of more processing and memory use over speed, you can draw things to a 32 bit image and then copy this image to the canvas. You can then use any interactions on the canvas to determine the coordinates to examine for transparency information on the source image.kernadec wrote: Mon Mar 13, 2023 8:21 pmHi, Stargate ok thank you,
but the canvas is a drawing surface where you can use transparency but you can't recover color from fades to transparency
so why stay in 24 bits i think it's time now that the machines are more advanced with giga of ram so why not CanvasGadget
Re: CanvasGadget Function Point(x,y) in RGBA
hi, Demivec thank you, ok there is ImageGadget() to do that thank you. but like CanvasGadget()
is designed for drawing, I don't see why it should stay 24 bit
while we now have 64-bit processors and all images have
at least 32 bit why stay with canvasGadget in 24 bit
Best Regard
is designed for drawing, I don't see why it should stay 24 bit
while we now have 64-bit processors and all images have
at least 32 bit why stay with canvasGadget in 24 bit
Best Regard
Re: CanvasGadget Function Point(x,y) in RGBA
Maybe I misunderstand your comment, but why you think, "all images have at least 32 bit", and what has it to do with the processor word size of 64 bit, nowadays? Do we talk about storage size or color depth?kernadec wrote: Wed Mar 15, 2023 9:20 am hi, Demivec thank you, ok there is ImageGadget() to do that thank you. but like CanvasGadget()
is designed for drawing, I don't see why it should stay 24 bit
while we now have 64-bit processors and all images have
at least 32 bit why stay with canvasGadget in 24 bit
Best Regard
Yes of course, you can store a color in a Long (32 bit) or Quad (64 bit) integer field, but this doesn't change the fact that the canvas drawing area has no alpha channel and contains only opaque colors (RGB, color depth 24 bit). There is no alpha information in the canvas gadget.
Ok, now you can say, Point() could return here always 255 for alpha channel, if the drawing context is opaque, to be consistent with 32 bit images, where an opaque color has an alpha of 255.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: CanvasGadget Function Point(x,y) in RGBA
hi, why so much discussion around a request as simple as this one.
To sum up,
Fred should give us the alpha channel for CanvasGadget()
all is said
Best Regard
To sum up,
Fred should give us the alpha channel for CanvasGadget()
all is said
Best Regard
Re: CanvasGadget Function Point(x,y) in RGBA
The way I see it...
I Think about CanvasGadget as if it were a reallife canvas, where you pain with watercolors, the more water you use, the more transparent your stroke will be, but once the canvas is finished it has no information on how much water you have used, you will only see the result color of merge the color and water.
In CanvasGadget you can draw (or paste images) with their alpha channel and the result in CanvasGadget will be correct as mix, but you can't expect to get a unique alpha value, because the image you see is the mixture of the colors and their alpha channels.
Could Fred implement some alpha channel where you draw, add subtract... ? Possibly, but IMHO I can't see the utility
I Think about CanvasGadget as if it were a reallife canvas, where you pain with watercolors, the more water you use, the more transparent your stroke will be, but once the canvas is finished it has no information on how much water you have used, you will only see the result color of merge the color and water.
In CanvasGadget you can draw (or paste images) with their alpha channel and the result in CanvasGadget will be correct as mix, but you can't expect to get a unique alpha value, because the image you see is the mixture of the colors and their alpha channels.
Could Fred implement some alpha channel where you draw, add subtract... ? Possibly, but IMHO I can't see the utility
Re: CanvasGadget Function Point(x,y) in RGBA
Sorry to interact again.kernadec wrote: Wed Mar 15, 2023 6:18 pm Fred should give us the alpha channel for CanvasGadget()
all is said
But if your feature request is to add an alpha channel to the CanvasGadget()
(in the sense of making the CanvasGadget() translucent),
then why didn't you request this in your first post and in the title?
Perhaps you can change your topic title for clarity.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: Fred, please CanvasGadget() and surface with alpha support
hi, I am an idiot.
and I do not master the English language.
Best Regard

and I do not master the English language.
Best Regard
Re: Fred, please CanvasGadget() and surface with alpha support
hi, @Caronte3D
the usefulness of alpha when drawing with alpha objects overlaid
on the canvas you will have colors whose alpha value you cannot get with the point(xy) command
and that's annoying because any drawing software does this perfectly
Best Regard
the usefulness of alpha when drawing with alpha objects overlaid
on the canvas you will have colors whose alpha value you cannot get with the point(xy) command
and that's annoying because any drawing software does this perfectly
Best Regard
Re: Fred, please CanvasGadget() and surface with alpha support
hi, here is an alpha test
in 24bit we obtain a color close truncated
Best Regard
in 24bit we obtain a color close truncated
Best Regard
Code: Select all
If OpenWindow(0, 0, 0, 300,300, "Test Canvas RGBA (alpha in 24bit)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
c.i = 0
c1.i = 0
b1.i = RGBA(Random(255),Random(105), 0, 100)
b2.i = RGBA(0, Random(255), Random(105), 100)
CanvasGadget(0, 10, 10, 280, 280, #PB_Canvas_Container)
If StartDrawing(CanvasOutput(0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(30, 50, 150, 150 ,b1)
Box(100, 120, 150, 150 ,b2)
DrawingMode(#PB_2DDrawing_AllChannels)
c = Point(120,140)
DrawText(10, 10, Str(b1),RGBA(255,255,255,255),b1)
DrawText(100, 10, Str(b2),RGBA(255,255,255,255),b2)
DrawText(190, 10, Str(c),RGBA(255,255,255,255),c)
Box(130, 145, 5, 5 ,c)
StopDrawing()
EndIf
;#########################################################
If OpenWindow(1, WindowX(0) + 330,WindowY(0) , 300,300, "Test ImageGadget 32bit", #PB_Window_SystemMenu)
If CreateImage(1,280, 280 ,32,#PB_Image_Transparent)
StartDrawing(ImageOutput(1))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(30, 50, 150, 150 ,b1)
Box(100, 120, 150, 150 ,b2)
DrawingMode(#PB_2DDrawing_AllChannels)
c1 = Point(130,140)
DrawText(10, 10, Str(b1),RGBA(255,255,255,255),b1)
DrawText(100, 10, Str(b2),RGBA(255,255,255,255),b2)
DrawText(190, 10, Str(c1),RGBA(255,255,255,255),c1)
StopDrawing()
ImageGadget(1, 10, 10, 280, 280, ImageID(1))
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(0))
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
c = Point(x,y)
DrawText(10, 20, Space(20),#White,#White)
DrawText(10, 20, Str(c),#White,c)
StopDrawing()
EndIf
EndIf
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Last edited by kernadec on Thu Mar 16, 2023 5:06 pm, edited 1 time in total.
Re: Fred, please CanvasGadget() and surface with alpha support
I don't know what you mean. If I use a color picker, the obtained color is the same your code shows
Re: Fred, please CanvasGadget() and surface with alpha support
hi, @Caronte3D
updated previous code to compare colors with imageGadget()
best Regard
updated previous code to compare colors with imageGadget()
best Regard
Re: Fred, please CanvasGadget() and surface with alpha support
-----
Last edited by kernadec on Thu Mar 16, 2023 5:33 pm, edited 1 time in total.