Q+A

<aside> 🧟 Put your two questions here. Please include your [name.](<http://name.Is>)

</aside>

getQucik is better used with images, correct? - Gonçalo

What can be more buggy, loading the loadPixels or getQucik? And which is better to work with? Guess it will depend on what we waat to create and can you give more exmaples- Gonçalo

getQuick(x, y) replaces get(x, y)  (you still need to loadPixels)

get(x, y) is safer
getQuick(x, y) is (much) faster

this means if you are not careful, getQuick can be buggy, but its not all that hard to be careful :)

if i'm doing pixel processing or generating i'd almost always use getQuick() (or write a similar function)

i might use just get() if i was only getting one pixel per frame (like maybe a color picker tool)

I think I used lerp color(?) to make gradients previously, and controlling the pixels like in the chapter makes a lot more sense, visually, to me- it’s connecting; however, I’m not sure how you would make a diagonal gradient? - Aamina

there are probably a few ways to you could make a diagonal gradient. 45° is pretty straightforward, but if you want an arbitrary angle I would probably do it the way I would do it in a shader..

i'm not sure how much sense this will make without code but your

1 take your x, y position of te pixel you want to color
2 rotate by an angel to get x2, y2 and then
3 just set the color that x2, y2 would have in a horizontal gradient

this is kind of like drawing a horizontal gradient and rotating it, but backwards.

UPDATE: I just posted a sketch on the sketch site that shows this.

My other question: I find the grass example really fun; could you add in movement with something we’ve already covered? like letting it loop? - Aamina

yes you could. i'm not sure if you could get realtime speed, but i think the grass example only reads (not writes) pixel data so it might be pretty fast, worth a sketch!

Can I use the get() and set() methods when I upload a smaller image? And when I upload a big image, I use loadPixels(). - Carmen Liu

i'm not quite sure i understand your question, but i think the answer is yes

Can we upload a dynamic gif or mov to generate pixel? And how we can do that? - Carmen

actually, i'm not sure. maybe. when i do that sort of thing, i usually export the video out to individual frame images and work with a bunch of images. this is actually pretty common in some more technical video workflows

Is there a reason why image pixels are stored as a 1D array instead of 2D array? The latter seems more intuitive for me. - Lawrence

the latter is more intuitive, for sure. but at the bottom of things computer memory has a 1 dimensional address. a 1d array more closely represents how the data is stored, it is simpler and it might be faster (depending on how things are done under the hood).

using a 2d address is much easier to think about most of the time. and getQuick is pretty much just an adapter. It takes a 2d address, and calculates the 1d address