After loading an image, how do I access the pixel color at some coordinate?
For example, it is easy in processing: Reference / Processing.org
I was not able to find this in the guide (Images - OPENRNDR GUIDE)
thanks.
After loading an image, how do I access the pixel color at some coordinate?
For example, it is easy in processing: Reference / Processing.org
I was not able to find this in the guide (Images - OPENRNDR GUIDE)
thanks.
Here’s an example on how to do it:
val image = loadImage("data/images/pm5544.png")
val shadow = image.shadow
shadow.download() // this is how you get hold of the pixel values
extend {
for (x in 0 until 76) {
for (y in 0 until 57) {
drawer.stroke = null
drawer.fill = shadow[((x / 76.0) * image.effectiveWidth).roundToInt(), ((y / 57.0) * image.effectiveHeight).roundToInt()]
drawer.rectangle(x * 10.0, y * 10.0, 10.0, 10.0)
}
}
}
Thank you, the shadow was what I needed.