obj
icon = 'object.dmi'
Click()
var/icon/i = icon(src.icon)
var/width = i.Width()
var/height = i.Height()
for(var/x = 1 to width)
for(var/y = 1 to height)
i.SwapColor(rgb(255, x, y), rgb(255 * rand(0, 1), 255 * rand(0, 1), 255 * rand(0, 1)))
src.icon = i
Problem description:
I use the above code to generate a coloured noise effect covering an entire icon. It works but it's slow. Outputting world.timeofday before and after gives about 4/10ths of a second to execute the code (which is noticable).
Is there a faster way to change the colour of a known pixel value or pixel location? I also tried DrawBox but it yields the same results.
In my case above, the width and height of the icon are 128 pixels.
I have other effects that I would like to do, but they requrie changing pixels are different positions in the icon, this method is too slow.
Also, is there any way to access a pixel at a known location like an array without using GetPixel?
Something like:
Which would give the colour at 1,1 in the icon and would set the colour of 5,5 to red.