# Coding Questions

**URL:** https://discourse.processing.org/c/processing/processing-questions/15.md?page=134

[Latest](https://discourse.processing.org/latest.md) · [Categories](https://discourse.processing.org/categories.md) · [Tags](https://discourse.processing.org/tags.md)

**Page:** 135

---

## [How to draw a Binary Tree?](https://discourse.processing.org/t/how-to-draw-a-binary-tree/12195)

<div class="topic-metadata">

**Author:** [@demsp](https://discourse.processing.org/u/demsp)\
**Replies:** 6\
**Last updated:** [June 21, 2019, 9:20pm UTC](https://discourse.processing.org/t/how-to-draw-a-binary-tree/12195 "2019-06-21T21:20:11Z")

</div>

This is an example of “Tree in Java”. Can i modify the Node\* class so that to draw the node like so class Node { int value; int x; // add x-coord int y; // add y-coord Node left; Node right; Node(int value, int x…

---

## [\[SOLVED\] PImage\[\] array inside class shows all images at once](https://discourse.processing.org/t/solved-pimage-array-inside-class-shows-all-images-at-once/12190)

<div class="topic-metadata">

**Author:** [@RealDwayneJ](https://discourse.processing.org/u/RealDwayneJ)\
**Replies:** 14\
**Last updated:** [June 21, 2019, 7:44pm UTC](https://discourse.processing.org/t/solved-pimage-array-inside-class-shows-all-images-at-once/12190 "2019-06-21T19:44:12Z")

</div>

Please note that this is just a portion of the full code. I made sure to isolate this portion only, with all its problems included. What it’s supposed to do: So, in the full code I have a program where you can hit a ce…

---

## [Clip() flickering](https://discourse.processing.org/t/clip-flickering/12227)

<div class="topic-metadata">

**Author:** [@lsk](https://discourse.processing.org/u/lsk)\
**Replies:** 1\
**Last updated:** [June 21, 2019, 11:08am UTC](https://discourse.processing.org/t/clip-flickering/12227 "2019-06-21T11:08:57Z")

</div>

I want to create an effect, where I have 2 source images which are copied onto a destination image made up of n tiles and then slide the tiles to reveal the other image. The way I want to achieve this is by copying a ti…

---

## [Threadsafe offscreen drawing?](https://discourse.processing.org/t/threadsafe-offscreen-drawing/12220)

<div class="topic-metadata">

**Author:** [@Rolf](https://discourse.processing.org/u/Rolf)\
**Replies:** 3\
**Last updated:** [June 21, 2019, 6:58am UTC](https://discourse.processing.org/t/threadsafe-offscreen-drawing/12220 "2019-06-21T06:58:36Z")

</div>

Here’s the idea I want to draw to a huge offscreen buffer usig thread(). Then I want to display the progress in the main window, in a scaled down size. Does not work, it displays the scaled down image, but only once t…

---

## [Trouble with if statments](https://discourse.processing.org/t/trouble-with-if-statments/12210)

<div class="topic-metadata">

**Author:** [@Asterioapo](https://discourse.processing.org/u/Asterioapo)\
**Replies:** 2\
**Last updated:** [June 20, 2019, 11:55pm UTC](https://discourse.processing.org/t/trouble-with-if-statments/12210 "2019-06-20T23:55:43Z")

</div>

Quite new to Processing and am trying to create a sort of create a character program where you chose options for them. I can get the options to cycle but am struggling to figure out the code to use so that if i press a k…

---

## [Rotating an image in the direction of the mouse](https://discourse.processing.org/t/rotating-an-image-in-the-direction-of-the-mouse/12211)

<div class="topic-metadata">

**Author:** [@marcholman23](https://discourse.processing.org/u/marcholman23)\
**Replies:** 2\
**Last updated:** [June 20, 2019, 5:33pm UTC](https://discourse.processing.org/t/rotating-an-image-in-the-direction-of-the-mouse/12211 "2019-06-20T17:33:37Z")

</div>

Hi, I would greatly appreciate it if somebody could correct my code. I want to maintain object orientation. The program is intended simply to rotate a car image in the direction of the mouse. class Car { PVector l…

---

## [Real newb having a NullPointerException. Help wanted](https://discourse.processing.org/t/real-newb-having-a-nullpointerexception-help-wanted/12206)

<div class="topic-metadata">

**Author:** [@MNeumann](https://discourse.processing.org/u/MNeumann)\
**Replies:** 1\
**Last updated:** [June 20, 2019, 3:26pm UTC](https://discourse.processing.org/t/real-newb-having-a-nullpointerexception-help-wanted/12206 "2019-06-20T15:26:45Z")

</div>

As the title suggests, I’m real new to Processing (read: Two weeks in), and I’m having a NullPointerException when trying to do make a maze game for a final project. The issue is occuring on line 216 if(potentialxpos \> …

---

## [How can i move the right rectangle using the up and down keys](https://discourse.processing.org/t/how-can-i-move-the-right-rectangle-using-the-up-and-down-keys/12201)

<div class="topic-metadata">

**Author:** [@joey\_2002](https://discourse.processing.org/u/joey_2002)\
**Replies:** 1\
**Last updated:** [June 20, 2019, 12:12pm UTC](https://discourse.processing.org/t/how-can-i-move-the-right-rectangle-using-the-up-and-down-keys/12201 "2019-06-20T12:12:37Z")

</div>

i’ve started like two days ago and i cant figure out how top move things using the keys. this is what i got so far a bit messy but it works. int x = 320; int y = 240; int dx = +10; int dy = -5; int rx = 600; int …

---

## [Set a path to different data folder](https://discourse.processing.org/t/set-a-path-to-different-data-folder/12021)

<div class="topic-metadata">

**Author:** [@OptOut](https://discourse.processing.org/u/OptOut)\
**Replies:** 3\
**Last updated:** [June 20, 2019, 10:20am UTC](https://discourse.processing.org/t/set-a-path-to-different-data-folder/12021 "2019-06-20T10:20:49Z")

</div>

Hi everybody, I have two different sets of images that I need to keep separate. I have one set of images in the regular data folder. I am selecting these images by putting them in an array PImage\[\] images = new PImage\[…

---

## [Calling selectFolder() using Thread()](https://discourse.processing.org/t/calling-selectfolder-using-thread/12177)

<div class="topic-metadata">

**Author:** [@tribblesontoast](https://discourse.processing.org/u/tribblesontoast)\
**Replies:** 5\
**Last updated:** [June 20, 2019, 1:37am UTC](https://discourse.processing.org/t/calling-selectfolder-using-thread/12177 "2019-06-20T01:37:34Z")

</div>

Hi, I’m getting data (approx 200,000 data points) I have generated from a text file, when the selectFolder method fires the callback and runs my method to process it, the program is of course locked into this course of …

---

## [Moving a Vehicle](https://discourse.processing.org/t/moving-a-vehicle/12107)

<div class="topic-metadata">

**Author:** [@marcholman23](https://discourse.processing.org/u/marcholman23)\
**Replies:** 7\
**Last updated:** [June 19, 2019, 4:26pm UTC](https://discourse.processing.org/t/moving-a-vehicle/12107 "2019-06-19T16:26:15Z")

</div>

Hi, I’m trying to create a program that allows the user to move a car with the up down right and left arrow keys. I want the up and down keys to accelerate backwards and forwards. I want the left and right keys to con…

---

## [Avoid 'clunky' sketch/framerate](https://discourse.processing.org/t/avoid-clunky-sketch-framerate/12041)

<div class="topic-metadata">

**Author:** [@OptOut](https://discourse.processing.org/u/OptOut)\
**Replies:** 24\
**Last updated:** [June 19, 2019, 4:10pm UTC](https://discourse.processing.org/t/avoid-clunky-sketch-framerate/12041 "2019-06-19T16:10:42Z")

</div>

Hi everybody, I am currently working on a project where I have an image wall 5 x 5 grid. The project selects and display random images from data folder after each iteration. I have hacked together a working demo over t…

---

## [\[SOLVED\] How to add ID to a shape (Java)?](https://discourse.processing.org/t/solved-how-to-add-id-to-a-shape-java/12155)

<div class="topic-metadata">

**Author:** [@NadeW](https://discourse.processing.org/u/NadeW)\
**Replies:** 4\
**Last updated:** [June 19, 2019, 5:09am UTC](https://discourse.processing.org/t/solved-how-to-add-id-to-a-shape-java/12155 "2019-06-19T05:09:12Z")

</div>

Hello I am unsure how to assign an ID to a specific shape. The idea is that every mousePressed will draw a circle in a grid, and I want to be able to tell which circle was drawn 1st, 2nd, 3rd etc. This is because I want …

---

## [Need my triangle to point to my mouse](https://discourse.processing.org/t/need-my-triangle-to-point-to-my-mouse/12053)

<div class="topic-metadata">

**Author:** [@Pan](https://discourse.processing.org/u/Pan)\
**Replies:** 2\
**Last updated:** [June 14, 2019, 9:34am UTC](https://discourse.processing.org/t/need-my-triangle-to-point-to-my-mouse/12053 "2019-06-14T09:34:19Z")

</div>

Hi, I’m using the google translator … I need the tip of my triangle to point to the coordinates of my mouse, here I leave what I could find out and do about it void setup(){ size(500, 500); } void draw(){ PVector …

---

## [Display JSON contents as text?](https://discourse.processing.org/t/display-json-contents-as-text/12139)

<div class="topic-metadata">

**Author:** [@RealDwayneJ](https://discourse.processing.org/u/RealDwayneJ)\
**Replies:** 4\
**Last updated:** [June 18, 2019, 3:42pm UTC](https://discourse.processing.org/t/display-json-contents-as-text/12139 "2019-06-18T15:42:25Z")

</div>

I’ve seen countless examples so far where the contents of a JSON file are displayed with println. But how would one run those contents through a simple text() in processing? Because I’ve been trying to get the array bel…

---

## [Drawing a 2D tile based map](https://discourse.processing.org/t/drawing-a-2d-tile-based-map/12101)

<div class="topic-metadata">

**Author:** [@InferNova](https://discourse.processing.org/u/InferNova)\
**Replies:** 2\
**Last updated:** [June 18, 2019, 12:13am UTC](https://discourse.processing.org/t/drawing-a-2d-tile-based-map/12101 "2019-06-18T00:13:10Z")

</div>

Hey guys, I have a problem with drawing large tile maps as this has performance issues. Any take’s ? Sorry for the vague description but in a rush. I am talking about a 2D tile grid like showcased with my Hiscapes game d…

---

## [Program stops running at some point](https://discourse.processing.org/t/program-stops-running-at-some-point/11985)

<div class="topic-metadata">

**Author:** [@Hjtunfgb](https://discourse.processing.org/u/Hjtunfgb)\
**Replies:** 5\
**Last updated:** [June 17, 2019, 10:10pm UTC](https://discourse.processing.org/t/program-stops-running-at-some-point/11985 "2019-06-17T22:10:17Z")

</div>

I have a program that searches for all the frames in a 864.000 frame video to spot the different ones and save them for me. But for some reason, the program stops running at around 10% of the progress. The video is the f…

---

## [Rotating LaserBeam](https://discourse.processing.org/t/rotating-laserbeam/12134)

<div class="topic-metadata">

**Author:** [@Not\_River](https://discourse.processing.org/u/Not_River)\
**Replies:** 1\
**Last updated:** [June 17, 2019, 9:22pm UTC](https://discourse.processing.org/t/rotating-laserbeam/12134 "2019-06-17T21:22:02Z")

</div>

In my class we are trying to design a video game, and I’m trying to use code a laser beam that an enemy shoots. The laser is meant to start at the eye, and rotate 90 degrees in the direction of of player. In my code, I’v…

---

## [3D camera view: TOP VIEW](https://discourse.processing.org/t/3d-camera-view-top-view/12019)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.processing.org/u/alice)\
**Replies:** 3\
**Last updated:** [June 12, 2019, 7:20pm UTC](https://discourse.processing.org/t/3d-camera-view-top-view/12019 "2019-06-12T19:20:59Z")

</div>

Hello everybody, Someone knows how to set the camera in processing in order to have the TOP view? and move It in x or y to find the object ? Thanks!

---

## [Pdf Limitations? how to produced highest quality output?](https://discourse.processing.org/t/pdf-limitations-how-to-produced-highest-quality-output/12104)

<div class="topic-metadata">

**Author:** [@Rolf](https://discourse.processing.org/u/Rolf)\
**Replies:** 3\
**Last updated:** [June 17, 2019, 6:31pm UTC](https://discourse.processing.org/t/pdf-limitations-how-to-produced-highest-quality-output/12104 "2019-06-17T18:31:16Z")

</div>

Hi there just written a program that draws tens of thousands of lines and exports the result to pdf. everything works fine, but when I open the pdf file with edge, nothing appears, when I open the file with Firefox, th…

---

## [Working with PImages in a 2D-array](https://discourse.processing.org/t/working-with-pimages-in-a-2d-array/12099)

<div class="topic-metadata">

**Author:** [@TTG](https://discourse.processing.org/u/TTG)\
**Replies:** 1\
**Last updated:** [June 17, 2019, 1:38pm UTC](https://discourse.processing.org/t/working-with-pimages-in-a-2d-array/12099 "2019-06-17T13:38:37Z")

</div>

Hi team. I have images in a 2d-array. each image is representing a colored image and acts as a timestamp having the colors representing a value The images contain 12 months and for each month 16 hrs ( 2D-array= \[12\]…

---

## [Progress bar from inside draw()](https://discourse.processing.org/t/progress-bar-from-inside-draw/12091)

<div class="topic-metadata">

**Author:** [@toby](https://discourse.processing.org/u/toby)\
**Replies:** 8\
**Last updated:** [June 17, 2019, 8:38am UTC](https://discourse.processing.org/t/progress-bar-from-inside-draw/12091 "2019-06-17T08:38:45Z")

</div>

Hello fellow Processing enthusiasts. Inside my draw() I have a tight loop working on pixels (I’m drawing fractals) and I’d like to have a progress bar reflecting how far draw() has got in its loop. I can do this fine if…

---

## [Web scrapper refresh/re-fetch question](https://discourse.processing.org/t/web-scrapper-refresh-re-fetch-question/12086)

<div class="topic-metadata">

**Author:** [@zara2355](https://discourse.processing.org/u/zara2355)\
**Replies:** 8\
**Last updated:** [June 16, 2019, 8:51pm UTC](https://discourse.processing.org/t/web-scrapper-refresh-re-fetch-question/12086 "2019-06-16T20:51:49Z")

</div>

Hey all, super new to Processing, so apologies if this is a dumb question… With the help of a few folks here on the forum, Ive cobbled together a web scrapper (code below) One of the things i would like to do is regula…

---

## [Cyclical Path Following](https://discourse.processing.org/t/cyclical-path-following/12072)

<div class="topic-metadata">

**Author:** [@LordCacops](https://discourse.processing.org/u/LordCacops)\
**Replies:** 2\
**Last updated:** [June 16, 2019, 12:03am UTC](https://discourse.processing.org/t/cyclical-path-following/12072 "2019-06-16T00:03:40Z")

</div>

Hello! I have the following code written by Daniel Shiffman. It makes vehicles follow a complex path. I thought that by joining the vertices of the shape I would have the vehicles go round the path cyclically, but inste…

---

## [Counting total drag rotation about a point](https://discourse.processing.org/t/counting-total-drag-rotation-about-a-point/12079)

<div class="topic-metadata">

**Author:** [@ddownn](https://discourse.processing.org/u/ddownn)\
**Replies:** 2\
**Last updated:** [June 15, 2019, 11:21pm UTC](https://discourse.processing.org/t/counting-total-drag-rotation-about-a-point/12079 "2019-06-15T23:21:12Z")

</div>

I was hoping to make something like an encoder wheel that would take a measurement of the accumulated rotation angle during a mouse drag around a center point. This code works fairly well for the main idea, but .angleBe…

---

## [Horrible fringing artefacts](https://discourse.processing.org/t/horrible-fringing-artefacts/12077)

<div class="topic-metadata">

**Author:** [@zenglenn](https://discourse.processing.org/u/zenglenn)\
**Replies:** 8\
**Last updated:** [June 15, 2019, 4:07pm UTC](https://discourse.processing.org/t/horrible-fringing-artefacts/12077 "2019-06-15T16:07:17Z")

</div>

Hi, I’m having this problem when using this particular process of drawing an image multiple times to the screen. I’m getting either white or black fringing, depending on which renderer I use (Default / OpenGL). I imag…

---

## [Delaying function blocks?](https://discourse.processing.org/t/delaying-function-blocks/12054)

<div class="topic-metadata">

**Author:** [@Pbchocochipcheerios](https://discourse.processing.org/u/Pbchocochipcheerios)\
**Replies:** 11\
**Last updated:** [June 15, 2019, 11:43am UTC](https://discourse.processing.org/t/delaying-function-blocks/12054 "2019-06-15T11:43:47Z")

</div>

Hi there, I am very very new to processing. I have created 4 different function blocks. Is there a way to have one function run for 3 seconds, and then switch to the next function for 3 seconds, etc, etc? when I put the…

---

## [Objects, texts and array - need help with arrange](https://discourse.processing.org/t/objects-texts-and-array-need-help-with-arrange/12058)

<div class="topic-metadata">

**Author:** [@patrushka](https://discourse.processing.org/u/patrushka)\
**Replies:** 4\
**Last updated:** [June 14, 2019, 6:15pm UTC](https://discourse.processing.org/t/objects-texts-and-array-need-help-with-arrange/12058 "2019-06-14T18:15:18Z")

</div>

Hey everyone :slight\_smile: i am new to processing and starting to work with arrays, I want to make a nice typography poster with it. so I thought it would look cool to place some objects on the poster, but the problem…

---

## [Nested loops and asterisk patterns](https://discourse.processing.org/t/nested-loops-and-asterisk-patterns/12015)

<div class="topic-metadata">

**Author:** [@otorp2](https://discourse.processing.org/u/otorp2)\
**Replies:** 9\
**Last updated:** [June 14, 2019, 6:09pm UTC](https://discourse.processing.org/t/nested-loops-and-asterisk-patterns/12015 "2019-06-14T18:09:32Z")

</div>

hi i know this isn’t very appealing visually but I’m trying to learn how to control nested loops - whats a good way to use nested loops and text to create asterisk patterns (simple triangle, diamond etc). thanks for h…

---

## [Diamond square shaped pixelation of an image](https://discourse.processing.org/t/diamond-square-shaped-pixelation-of-an-image/11990)

<div class="topic-metadata">

**Author:** [@Ruchi](https://discourse.processing.org/u/Ruchi)\
**Replies:** 1\
**Last updated:** [June 14, 2019, 5:05pm UTC](https://discourse.processing.org/t/diamond-square-shaped-pixelation-of-an-image/11990 "2019-06-14T17:05:41Z")

</div>

Hi, is there a way to get diamond square shaped pixels or for that matter give different shapes pixelation to an image just like photoshop in processing?

[Previous page](https://discourse.processing.org/c/processing/processing-questions/15.md?page=133)

[Next page](https://discourse.processing.org/c/processing/processing-questions/15.md?page=135)
