Is there a way to get the RGB color value at a given point on the layout, or at a given point in a canvas.
I'm interested in getting the RGB color clicked, in the standard eyedropper fashion.
I know you can get this kind of information from the image manipulator, but I'm not sure if there is a way to get the layout or canvas graphical data into the image manipulator.
yes you can, but its very slow.
you need a canvas to capture the point you're selecting (im pretty sure it can be one pixel in size and still worm for minimal vram usage) then you need to "copy from sprite" with the image manip, then you need to use the getR getG getB expressions which are a part of image manip once the image has been copied. thats pretty much it
the image manip doesnt use screen coordinates when it copies, so 0,0 is not going to be 0,0 on the layout in the getR/G/B expression, its going to be 0,0 on the currently copied image. if your image is larger than 1x1, and isnt placed with its topleft corner at 0,0 on the layout, you going to need to transform coordinates so that theyre "local" to the images topleft coordinates instead of the layout.
just ask if you're having trouble getting it to work because explaining it like this is kinda cryptic.
also note that this series of event is very hammering on the framerate due to its slow gpu to cpu transfer nature so your not gonna be wanting to do it for longer than one frame (another disadvantage to hardware acceleration, albeit not a very big one)
Thanks for the reply, I just noticed after posting that you can copy from a canvas object with the "Copy from sprite" action, but reading your response it sounds like you're saying you can get the color at an arbitrary point in the layout.
For the project I'm working on, getting color data out of a canvas object might be all I need, but I'm still curious if it's possible to get the color at an arbitrary point in the layout, as it would grant me quite a bit more flexibility.
You said you can use the canvas to "capture the point you're selecting". Does this mean there is a way to capture a point in the layout rather than merely pasting an object into the canvas? Or would you have to paste every object into the canvas and then get the resulting color at the desired point. If that's the case, I can see what you mean when you say it's slow. As it is, just moving an image from a canvas to the image manipulator seems to hit the CPU a bit hard.
i havn't ever done this, but you could probably get away with putting your canvas on a forward layer over everything you'd like to get a colour from, make the canvas 1 pixel by 1 pixel in size (its all you need to check right?) then enable grab layout before or after drawing (wtv works i forget which one youd use) on the canvas in its properties, and after that with your events position the canvas at the coordinates you wanna pick from and do blablabla image manipulator stuff, you know the rest.
using the grab layout after(?) drawing ability of the canvas should enable you to circumvent having to paste everything, and moving the 1x1 canvas should enable you to get the color at any arbitrary point.
i dont know the exact timing of when/what the image manip actually would be copying is, so it might be 1 frame delayed, not a problem if your color testing something relatively static/slow moving.
Develop games in your browser. Powerful, performant & highly capable.
Wow! "Grab Layout".
I can't believe I didn't see that.
Awesome. Thanks, I'm definitely going to try that out.