# Using Pixels\[\] Array over Points • trying to move Pixels(XY) off screen like Points

**URL:** https://discourse.processing.org/t/using-pixels-array-over-points-trying-to-move-pixels-xy-off-screen-like-points/24309
**Category:** Coding Questions
**Created:** [October 3, 2020, 4:26pm UTC](https://discourse.processing.org/t/using-pixels-array-over-points-trying-to-move-pixels-xy-off-screen-like-points/24309 "2020-10-03T16:26:04Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [October 5, 2020, 10:28am UTC](https://discourse.processing.org/t/using-pixels-array-over-points-trying-to-move-pixels-xy-off-screen-like-points/24309/2 "2020-10-05T10:28:16Z")

</div>

Hello,

Cool stuff!

> [@Gus\_Fermin](#):
>
> A beginner here

I feel like that with every new topic I learn.

I was inspired and sharing my initial exploration of this:

> **Code here**
>
> ```auto
> // Pixel Exploration
> // v1.0.0
> // GLV 2020-10-05
> // Inspired by topic:
> // https://discourse.processing.org/t/using-pixels-array-over-points-trying-to-moving-pixels-xy-off-screen-like-points/24309
> 
> PImage img, img2, img3;
> float mod;
> int counter;
> int choice = 1;
> 
> void setup() 
> {
> size(500, 500, P3D);
> frameRate(60);
> img = loadImage("http://learningprocessing.com/code/assets/sunflower.jpg");
> //img.loadPixels();
> background(0);
>   
> img2 = createImage(400, 400, ARGB);
> //img2.loadPixels();
> for (int i = 0; i < img2.width*img2.height ; i++)
> {
> img2.pixels[i] = color(0, 255);
> }
> //img2.updatePixels();
> }
> 
> void draw() 
> {  
> //Sinusoidal modulation from 0 to 2
> mod = 1+1*sin(counter*TAU/500-TAU/4);
> counter++;
>   
> switch(choice) 
> {
> case 1: 
> println("Plot 1");
> plot1();
> break;
> case 2: 
> println("Plot 2");
> plot2();
> break;
> case 3: 
> println("Plot 3");
> plot3();
> break;
> case 4: 
> println("Plot 4");
> plot4();
> break;      
> default:
> println("Woops!"); 
> break;
> }
> 
> surface.setTitle(str(frameRate));
> }
>   
> // **********************************************************************************
> 
> void plot1()
> {
> fill(0, 5);
> noStroke();
> rect(0, 0, width, height);  
>   
> for (int x = 0; x < img.width; x++ ) 
> {
> for (int y = 0; y < img.height; y++ ) 
> {
> // Pixel location and color
> color c = img.get(x, y);
> float sz = (brightness(c)/255)*mod;
> set(int(x*sz), int(y*sz), c);      
> }
> }  
> }
> 
> // **********************************************************************************
> 
> void plot2()
> {  
> fill(0, 5);
> noStroke();
> rect(0, 0, width, height);  
>   
> for (int x = 0; x < img.width; x++ ) 
> {
> for (int y = 0; y < img.height; y++ ) 
> {
> // Pixel location and color
> color c = img.pixels[x+img.width*y];
> float sz = (brightness(c)/255)*mod;
> set(int(x*sz), int(y*sz), c);
> }
> }
> }
> 
> // **********************************************************************************  
>   
> void plot3()
> {
> fill(0, 5);
> noStroke();
> rect(0, 0, width, height);    
>     
> for (int x = 0; x < img.width; x++ ) 
> {
> for (int y = 0; y < img.height; y++ ) 
> {
> // Pixel location and color
> color c = img.pixels[x+img.width*y];
> float sz = (brightness(c)/255)*mod;
> //sz = 1; // Try this to see original image.
> img2.pixels[int(x*sz)+int(y*sz)*400] = c;    
> }
> }
> img2.updatePixels();  
> image(img2, 0, 0);     
> }
>   
> // **********************************************************************************  
>   
> void plot4()
> {
> // Sets pixel array to a fixed color with transparency  
> for (int i = 0; i < img2.width*img2.height ; i++)
> {
> img2.pixels[i] = color(0, 5);
> }
>   
> for (int x = 0; x < img.width; x++ ) 
> {
> for (int y = 0; y < img.height; y++ ) 
> {
> // Pixel location and color
> color c = img.pixels[x+img.width*y];
> float sz = brightness(c)/255*mod;
> //sz = 1; // Try this to see original image.
> //c = color(255, 255, 0); //Test with fixed color
> img2.pixels[int(x*sz)+int(y*sz)*400] = c;      
> }
> }
> img2.updatePixels();  
> image(img2, 0, 0);    
> }  
>   
> void keyPressed()
> {
> counter = 0;
> choice++;
> if (choice >4)
> choice = 1;
> }
> 
> ```

I did not scrutinize your code and instead did an exploration of this.

`:)`

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8001d4e5fb6f6d0a8b4462af184689d8b1a01b14.jpeg)

---

_[View the full topic](https://discourse.processing.org/t/using-pixels-array-over-points-trying-to-move-pixels-xy-off-screen-like-points/24309)._
