# Alternative to get() for faster performance?

**URL:** https://discourse.processing.org/t/alternative-to-get-for-faster-performance/30228
**Category:** Coding Questions
**Created:** [May 23, 2021, 12:21am UTC](https://discourse.processing.org/t/alternative-to-get-for-faster-performance/30228 "2021-05-23T00:21:03Z")
**Posts on this page:** 1
**Showing post:** 8

<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: [May 30, 2021, 3:04pm UTC](https://discourse.processing.org/t/alternative-to-get-for-faster-performance/30228/8 "2021-05-30T15:04:48Z")

</div>

Hello,

This topic inspired me!

Something I worked on:

> **Example of random tiling \< Click here to see code!**
>
> ```auto
> // Pixel Manipulation 
> // v1.0.0
> // GLV 2021-05-30
> 
> let img;
> let cap;
> 
> function setup() 
> {
> createCanvas(640, 480); // Set to video size
>   
> img = createGraphics(width, height);
> 
> pixelDensity(1);    
> img.pixelDensity(1);
>   
> cap = createCapture(VIDEO);
> cap.hide(); 
>   
> //d = pixelDensity(); // Future! See references.
> }
> 
> function draw() 
> { 
> cap.loadPixels();
> img.loadPixels();
>   
> tilesX = 10;
> tilesY = 10;
>   
> //samples = map(mouseX, 0, width, 0, 2000);
> samples = 200; 
>   
> for (let i = 0; i<samples; i++)
> {
> x = (random(width))| 1; // Converts to int
> y = int(random(height)); // Converts to int 
>       
> let loc = x + y*cap.width;
>   
> // Copy a tile from capture to pixels     
> for (let xt = x; xt < x+tilesX; xt++) 
> {
> for (let yt = y; yt < y+tilesY; yt++) 
> {        
> let loct = (xt + yt*cap.width)*4;
>         
> img.pixels[loct + 0] = cap.pixels[loct + 0]; //r
> img.pixels[loct + 1] = cap.pixels[loct + 1]; //g
> img.pixels[loct + 2] = cap.pixels[loct + 2]; //b
> img.pixels[loct + 3] = cap.pixels[loct + 3]; //a
> }
> }
> }    
>     
> img.updatePixels();
> image(img, 0, 0);
>   
> // Display data
> fill(255);
> stroke(1);
> textSize(18);
> text(frameRate()|1, 10, 20);
> text(samples, 10, 40);
> }
> 
> ```

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

A very cool effect!

`:)`

---

_[View the full topic](https://discourse.processing.org/t/alternative-to-get-for-faster-performance/30228)._
