Change and read individual pixel colours?
-
I don't think you can read them...
-
What about making an array of pixel data (rgb values), and then using uploadImage to turn that array into an image?
-
@DaddyJDM
I’ll give that a go. Currently made an array containing all pixel positions and colours. will try to update the colours on the fly with that. Gonna make Langton ant to give it a test -
uploadImage()
wouldn't really be suitable for cases where you want stuff plotted by algorithms that are dynnamically changing which is what I assume we are talking about here so yes, plot is the way to go (or box, or circle perhaps?)Sadly, no you cannot read pixels. So you cannot get the colour at screen position X / Y.
Also just something to be aware of:
uploadImage()
has a memory leak in the current retail version but it is fixed in the next version. -
@Martin
Cheers, I’ve noticed an error that keeps getting thrown back. When trying to use a screen resolution larger than 160x100 while storing every pixels x, y and colour in a struct array I get a stack overflow. I know storing 3 bits of information on 900000+ array elements is pushing it and wasn’t expecting full 1280x720 but is a stack overflow expected for a resolution as low as 200x200? -
Can you show / type the code please? The simple answer is no, I would not expect problems with 200x200 but I'd like to see whats going on really.
-
@Martin
setmode(160,100)
Struct pix
Int x
Int y
String color
Endstructpix pixels[gheight()*gwidth()]
This throws up a stack overflow on any values larger or just freezes meaning I have to restart FUZE
-
Thank you - I'll investigate when I get a moment
-
@daddy-devito166
Probably not the cause of your problem, but shouldn't colour be stored as a vector rather than a string. When you use the colour names, they just refer to the corresponding rbga vector. -
@Richard
I’ll take a look, the stack overflow always points to that array though -
It would also be useful to
print(len(pixels))
andprint(len(pixels[0]))
just to be absolutely sure thatgHeight()
andgWidth()
are returning the values of the new mode - of course they should!The comment about string is valid.
Another thing I would try, just to see what happens is if you have 3 separate arrays instead of an array of structs.
Please note, these are all debug steps to try and narrow the problem. I won't get to actually try anything on my Switch until later this evening.
-
Try setting gwidth() and gheight() to variables first and then put those in your array declaration. It’s worth a try!
-
@toxibunny
Will do! Tbh might drop the full code as the puzzle is getting stranger and stranger and with lowering the res to avoid stack overflows I can’t read error messages anymore!