# Drawing a buffer to the canvas, while maintaining vectors (instead of rasterizing the buffer)?

**URL:** https://discourse.processing.org/t/drawing-a-buffer-to-the-canvas-while-maintaining-vectors-instead-of-rasterizing-the-buffer/24343
**Category:** Processing
**Created:** [October 4, 2020, 9:14pm UTC](https://discourse.processing.org/t/drawing-a-buffer-to-the-canvas-while-maintaining-vectors-instead-of-rasterizing-the-buffer/24343 "2020-10-04T21:14:32Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [October 6, 2020, 4:11am UTC](https://discourse.processing.org/t/drawing-a-buffer-to-the-canvas-while-maintaining-vectors-instead-of-rasterizing-the-buffer/24343/10 "2020-10-06T04:11:39Z")

</div>

it seems like what you want though might instead be threads. These are processes which you can call which run alongside the main thread, and execute in the background. You CANNOT use draw with thread but you can do calculations, and so long as you have variables to track what has been calculated or not, the thread should not revisit the same elements.

Threads do have some limitations though, mainly they can be a bit difficult to implement for beginners and they run asynchronously. meaning if you have more than one thread they’re wont run in the order you want unless you create a synchronized thread.

This will mean that you cannot combine thread and canvas as no draw calls can be made with thread, but you should be able to store as many calculations as you want, and providing a flag is set when done, you can then retrieve the coordinates and raster it wherever you want.

> **[thread() / Reference](https://processing.org/reference/thread_.html)**
>
> Processing sketches follow a specific sequence of steps: setup() first, followed by draw() over and over and over again in a loop. A thread is also a series of steps with a beginning, a …

> **[Synchronization in Java - GeeksforGeeks](https://www.geeksforgeeks.org/synchronization-in-java/)**
>
> A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

> **[Synchronization in Java - javatpoint](https://www.javatpoint.com/synchronization-in-java)**
>
> Synchronization in java thread with java synchronized method, synchronized block, static synchronization and inter thread communication with examples on static synchronization, synchronized method, synchronized block, inter-thread communication etc.

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/5886/multithreading-madness#Item_17)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

> [@PThreading: A framework for multithreaded drawing in Processing](https://discourse.processing.org/t/pthreading-a-framework-for-multithreaded-drawing-in-processing/14782):
>
> PThreading: A framework for multithreaded drawing in Processing Getting started, motivation, download and example usage available from [Github](https://github.com/micycle1/PThreading). Natively, Processing runs on a single thread, which can lead to poor performance on draw-heavy sketches. In short, the framework consists of two classes: PThread and PThreadManager. Override the PThread class with Processing code and then add instances of your new class to a PThreadManager; this will run the instances as threads that draw into your Pro…

> [@Passing a parameter through a thread](https://discourse.processing.org/t/passing-a-parameter-through-a-thread/21498):
>
> Hi again everyone, currently stuck on a problem, I wish to create multiple threads to maximize cpu usage as I understand processing only uses the one thread by default, (perhaps this is java by default). I have done some research and converted a piece of code I found to work in processing. class A implements Runnable { String to\_print; int t; A(String to\_print) { this.to\_print = to\_print; } A(Integer t) { this.t = t; } //public void run() { // System.out.println(to\_p…

---

_[View the full topic](https://discourse.processing.org/t/drawing-a-buffer-to-the-canvas-while-maintaining-vectors-instead-of-rasterizing-the-buffer/24343)._
