I would like to change pixels of an HTML5 canvas
to an hsl
value. It could be any hsl
value that is chosen by the user.
I can get the canvas imageData with var imageData = canvas.getImageData(0, 0, 200, 200);
But the imageData.data
array contains values in rgba
. Actually each value in the array is a byte so -
data[0] = r, data[1] = b, data[2] = g, data[3] = a, data[4] = r, data[5] = b, data[6] = g, data[7] = a
etc.
Is there an api
that can be used to manipulate imageData? An api
that would abstract the raw data so that - data[0] = rgba, data[1] = rgba
etc?
And that might have methods like - data[0].setValueHSL(60, 100%, 50%);
If this api does not exist is there a class that can create/represent an hsl value and which can convert the value to rgb?