# Coding Questions

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

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

**Page:** 110

---

## [Trying to color an image using a palette](https://discourse.processing.org/t/trying-to-color-an-image-using-a-palette/17572)

<div class="topic-metadata">

**Author:** [@pacoruiz](https://discourse.processing.org/u/pacoruiz)\
**Replies:** 2\
**Last updated:** [February 6, 2020, 10:12am UTC](https://discourse.processing.org/t/trying-to-color-an-image-using-a-palette/17572 "2020-02-06T10:12:50Z")

</div>

Hi. Im trying to make an sketch that takes an image and an array of five colors and change all pixels and substitute them for the color of the array that have hue and saturation more closer to that point, letting the br…

---

## [How to save high score?](https://discourse.processing.org/t/how-to-save-high-score/17566)

<div class="topic-metadata">

**Author:** [@nati1704](https://discourse.processing.org/u/nati1704)\
**Replies:** 2\
**Last updated:** [February 6, 2020, 6:50am UTC](https://discourse.processing.org/t/how-to-save-high-score/17566 "2020-02-06T06:50:54Z")

</div>

Hey, I have to make a little game for school project. I have little problem - I have no idea how to save a high score I need a txt document right, but how do I insert data from the document into the game? Thanks

---

## [Creating array of colors with lerpColor](https://discourse.processing.org/t/creating-array-of-colors-with-lerpcolor/17554)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 2\
**Last updated:** [February 5, 2020, 7:55pm UTC](https://discourse.processing.org/t/creating-array-of-colors-with-lerpcolor/17554 "2020-02-05T19:55:24Z")

</div>

@Chrisir (I don’t know what happened to my response as I had withdrawn the topic. But am reposting the response here…) No problem at all!! I was just now working on this and have arrived at the following solution. M…

---

## [Tracing a point on a moving circle](https://discourse.processing.org/t/tracing-a-point-on-a-moving-circle/17544)

<div class="topic-metadata">

**Author:** [@ndelong91](https://discourse.processing.org/u/ndelong91)\
**Replies:** 1\
**Last updated:** [February 4, 2020, 7:35pm UTC](https://discourse.processing.org/t/tracing-a-point-on-a-moving-circle/17544 "2020-02-04T19:35:05Z")

</div>

I am trying to create an animation of a cardioid, I currently have 2 circles: one is set to (0, 0) translated to width/2, height/2 (center). the other is moving around the stationary I would like to start at point(-1…

---

## [Distance Checking of Static Objects](https://discourse.processing.org/t/distance-checking-of-static-objects/17519)

<div class="topic-metadata">

**Author:** [@zavierboyles](https://discourse.processing.org/u/zavierboyles)\
**Replies:** 1\
**Last updated:** [February 4, 2020, 8:34am UTC](https://discourse.processing.org/t/distance-checking-of-static-objects/17519 "2020-02-04T08:34:26Z")

</div>

Hi. I’m trying to draw an array of 9 flowers in such a way that there is no overlap and the centres are on within the boundaries of the canvas. I’ve come up with a method so that the flowers are at least spawning far en…

---

## [Avoiding tile overlap (of colorful plastic toy shapes)](https://discourse.processing.org/t/avoiding-tile-overlap-of-colorful-plastic-toy-shapes/17525)

<div class="topic-metadata">

**Author:** [@mortap](https://discourse.processing.org/u/mortap)\
**Replies:** 1\
**Last updated:** [February 3, 2020, 9:59pm UTC](https://discourse.processing.org/t/avoiding-tile-overlap-of-colorful-plastic-toy-shapes/17525 "2020-02-03T21:59:17Z")

</div>

Below is code I’m working on to display those little plastic toy shapes (hexagon, triangle, square, etc…) and I wanted to find a way to prevent a new shape from overlapping previous ones. So far I have the shapes display…

---

## [Moving circle with arrow keys](https://discourse.processing.org/t/moving-circle-with-arrow-keys/10586)

<div class="topic-metadata">

**Author:** [@S.L.C.S](https://discourse.processing.org/u/S.L.C.S)\
**Replies:** 6\
**Last updated:** [February 3, 2020, 7:37pm UTC](https://discourse.processing.org/t/moving-circle-with-arrow-keys/10586 "2020-02-03T19:37:29Z")

</div>

hello everyone, I have an assignment that says i have to make a circle that moves when the arrow keys are pressed and it shouldn’t leave the canvas, but i’m having a problem with keeping the circle within the canvas…i n…

---

## [I need help I don’t know how to set it up](https://discourse.processing.org/t/i-need-help-i-don-t-know-how-to-set-it-up/17528)

<div class="topic-metadata">

**Author:** [@ImConfused](https://discourse.processing.org/u/ImConfused)\
**Replies:** 2\
**Last updated:** [February 3, 2020, 5:20pm UTC](https://discourse.processing.org/t/i-need-help-i-don-t-know-how-to-set-it-up/17528 "2020-02-03T17:20:13Z")

</div>

I have no clue how to setup this up I have to make a bunch of tiny squares change color

---

## [Problem with robot cursor](https://discourse.processing.org/t/problem-with-robot-cursor/2046)

<div class="topic-metadata">

**Author:** [@erwrow](https://discourse.processing.org/u/erwrow)\
**Replies:** 9\
**Last updated:** [February 3, 2020, 1:46pm UTC](https://discourse.processing.org/t/problem-with-robot-cursor/2046 "2020-02-03T13:46:14Z")

</div>

Greetings everyone! i was making a program that moves the camera and lets you ovserve an object from any direction (using w, a, s, d and the mouse, kinda like a game), to do that i use the robot class to restart the posi…

---

## [Minimum and maximum random numbers](https://discourse.processing.org/t/minimum-and-maximum-random-numbers/16888)

<div class="topic-metadata">

**Author:** [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Replies:** 12\
**Last updated:** [February 2, 2020, 2:54pm UTC](https://discourse.processing.org/t/minimum-and-maximum-random-numbers/16888 "2020-02-02T14:54:09Z")

</div>

I want to generate two random numbers. The numbers will be used to limit a range of hues (minimum 0, maximum 360). I can do it like this: float start; float end; //… start = random(0,360); end = start + random(45,90)…

---

## [Drawn object stops moving away?](https://discourse.processing.org/t/drawn-object-stops-moving-away/17493)

<div class="topic-metadata">

**Author:** [@jedslater](https://discourse.processing.org/u/jedslater)\
**Replies:** 2\
**Last updated:** [February 2, 2020, 3:11am UTC](https://discourse.processing.org/t/drawn-object-stops-moving-away/17493 "2020-02-02T03:11:01Z")

</div>

Hi there! I’ve been working on some sketches using the contours of a 3D object to draw onto the canvas. In order to give the appearance of the object (in this case a box) moving into the distance, I increment the value o…

---

## [saveFrame() doesn't match real time](https://discourse.processing.org/t/saveframe-doesnt-match-real-time/17397)

<div class="topic-metadata">

**Author:** [@BrokenCode](https://discourse.processing.org/u/BrokenCode)\
**Replies:** 2\
**Last updated:** [February 1, 2020, 9:02pm UTC](https://discourse.processing.org/t/saveframe-doesnt-match-real-time/17397 "2020-02-01T21:02:14Z")

</div>

Hello everyone, I have a very tricky question here. Why saveFrame() doesn’t write all the frames as it should? I mean, if I have a grid of 28 tiles (println(points.size());), and I wait 1 second to fill each tile: if (…

---

## [Problem making the ticks fit on the grid](https://discourse.processing.org/t/problem-making-the-ticks-fit-on-the-grid/17501)

<div class="topic-metadata">

**Author:** [@Priscilla\_van\_Gritte](https://discourse.processing.org/u/Priscilla_van_Gritte)\
**Replies:** 7\
**Last updated:** [February 2, 2020, 12:24am UTC](https://discourse.processing.org/t/problem-making-the-ticks-fit-on-the-grid/17501 "2020-02-02T00:24:41Z")

</div>

Regards, I have problems with ticking shoes on the grid. For example using the following code. public void setup(){ size(1000, 600, JAVA2D); background(17,34,51); // Color de fondo principal rect(-1, 95,…

---

## [Super simple code. What am I missing?](https://discourse.processing.org/t/super-simple-code-what-am-i-missing/17342)

<div class="topic-metadata">

**Author:** [@Tomfoolery](https://discourse.processing.org/u/Tomfoolery)\
**Replies:** 4\
**Last updated:** [February 1, 2020, 10:13pm UTC](https://discourse.processing.org/t/super-simple-code-what-am-i-missing/17342 "2020-02-01T22:13:59Z")

</div>

I’ll probably kick myself when somebody answers this but I just can’t figure out what’s wrong with my code. All I want is to increase the red value by .01 per frame. When I run it, the value doesn’t change at all. If I r…

---

## [Ideas to create elastic line animation - \[SOLVED\]](https://discourse.processing.org/t/ideas-to-create-elastic-line-animation-solved/17394)

<div class="topic-metadata">

**Author:** [@adaptinnovative](https://discourse.processing.org/u/adaptinnovative)\
**Replies:** 3\
**Last updated:** [February 1, 2020, 3:07am UTC](https://discourse.processing.org/t/ideas-to-create-elastic-line-animation-solved/17394 "2020-02-01T03:07:04Z")

</div>

I have drawn a horizontal line using points. I want to split the points in half so the line separate. Then the centre point rises vertically straight up the y-axis and the last point stays on the horizontal axis of x. Ho…

---

## [Creating a hit box?](https://discourse.processing.org/t/creating-a-hit-box/17469)

<div class="topic-metadata">

**Author:** [@lupos](https://discourse.processing.org/u/lupos)\
**Replies:** 1\
**Last updated:** [January 31, 2020, 1:41pm UTC](https://discourse.processing.org/t/creating-a-hit-box/17469 "2020-01-31T13:41:44Z")

</div>

I am having trouble with hit boxes, the enemy only stops when it gets to s specific point not when it touches the hole enemy and I can figure out how float X,Y,Xc,Yc,Xm,Ym,Xl,Xr,Yt,Yb; float H1,H2,H3,H1x,H1y,Ev; floa…

---

## [How to move an image including horizontal and vertical inversion](https://discourse.processing.org/t/how-to-move-an-image-including-horizontal-and-vertical-inversion/17473)

<div class="topic-metadata">

**Author:** [@all](https://discourse.processing.org/u/all)\
**Replies:** 3\
**Last updated:** [January 31, 2020, 3:31pm UTC](https://discourse.processing.org/t/how-to-move-an-image-including-horizontal-and-vertical-inversion/17473 "2020-01-31T15:31:33Z")

</div>

Hello, My aim is to get the same behavior than line(x1, y1, x2, y2) but with a PNG image image(img, x1, y1, x2, y2) using the imageMode(CORNERS); My PNG image have a transparent background and the line go from the uppe…

---

## [Pixel Sorting with threshold](https://discourse.processing.org/t/pixel-sorting-with-threshold/17462)

<div class="topic-metadata">

**Author:** [@Alexx](https://discourse.processing.org/u/Alexx)\
**Replies:** 1\
**Last updated:** [January 31, 2020, 8:39am UTC](https://discourse.processing.org/t/pixel-sorting-with-threshold/17462 "2020-01-31T08:39:26Z")

</div>

Hi. I’m new to Processing. Hope someone is able to help me. In my sketch the pixel sorting work on width, but I I need it to be vertical non horizontal … how? Thank you. This is the code: int mode = 0; int threshold…

---

## [Creating an enemy class](https://discourse.processing.org/t/creating-an-enemy-class/17223)

<div class="topic-metadata">

**Author:** [@lupos](https://discourse.processing.org/u/lupos)\
**Replies:** 6\
**Last updated:** [January 30, 2020, 10:53pm UTC](https://discourse.processing.org/t/creating-an-enemy-class/17223 "2020-01-30T22:53:12Z")

</div>

I am working on a school project and I am having trouble creating multiple enemies form one class. when I create an two enemies from the same class and when one gets hit they all disappear can someone help please. here …

---

## [How do I make a Stepped Grayscale gradation in grid arrays](https://discourse.processing.org/t/how-do-i-make-a-stepped-grayscale-gradation-in-grid-arrays/17437)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 7\
**Last updated:** [January 30, 2020, 10:08pm UTC](https://discourse.processing.org/t/how-do-i-make-a-stepped-grayscale-gradation-in-grid-arrays/17437 "2020-01-30T22:08:16Z")

</div>

I have 2 examples of attempts to figure out how to implement a gradation of grays to various grid array sketches. The first sketch is a bar grid with a single row of 7 cells. The second sketch is a 9 square grid with…

---

## [Rotating Canvas](https://discourse.processing.org/t/rotating-canvas/17108)

<div class="topic-metadata">

**Author:** [@Interkinactive](https://discourse.processing.org/u/Interkinactive)\
**Replies:** 9\
**Last updated:** [January 30, 2020, 3:48pm UTC](https://discourse.processing.org/t/rotating-canvas/17108 "2020-01-30T15:48:27Z")

</div>

Hi there, I’m stuck with this problem: I want to draw something on a rotating canvas. Working with PGraphics and saving my image as PImage for buffer. The canvas is rotating, but the coordinates of the mousepoint are ro…

---

## [SOLVED Draw\_Nodes Export to PDF has too many duplicated paths](https://discourse.processing.org/t/solved-draw-nodes-export-to-pdf-has-too-many-duplicated-paths/17444)

<div class="topic-metadata">

**Author:** [@new](https://discourse.processing.org/u/new)\
**Replies:** 0\
**Last updated:** [January 30, 2020, 12:01pm UTC](https://discourse.processing.org/t/solved-draw-nodes-export-to-pdf-has-too-many-duplicated-paths/17444 "2020-01-30T12:01:16Z")

</div>

Hi everyone, I am pretty new to processing and have haphazardly made my way through some code to get a graphic output for a poster I am making. The code comes from multiple sources so I am sure there is a lot of unneces…

---

## [2 threads Processing in Java IDE](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379)

<div class="topic-metadata">

**Author:** [@gerome](https://discourse.processing.org/u/gerome)\
**Replies:** 9\
**Last updated:** [January 30, 2020, 10:06am UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379 "2020-01-30T10:06:16Z")

</div>

In the course of rebuilding a big Processing project in a Java IDE (IntelliJ) on Windows 10 x64, Processing 3.5.4, I try to translate the old solution for running two Processing threads, one in 2D, one in 3D on differen…

---

## [Vertex shader displacement](https://discourse.processing.org/t/vertex-shader-displacement/17415)

<div class="topic-metadata">

**Author:** [@Geo\_Pi](https://discourse.processing.org/u/Geo_Pi)\
**Replies:** 1\
**Last updated:** [January 29, 2020, 3:26pm UTC](https://discourse.processing.org/t/vertex-shader-displacement/17415 "2020-01-29T15:26:19Z")

</div>

Hi, I’m in the process of learning OpenGL & GLSL. I’m trying to port to processing this THREE.js tutorial on vertex displacement shader https://www.clicktorelease.com/blog/vertex-displacement-noise-3d-webgl-glsl-three…

---

## [2D grid array question](https://discourse.processing.org/t/2d-grid-array-question/17189)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 19\
**Last updated:** [January 28, 2020, 11:16pm UTC](https://discourse.processing.org/t/2d-grid-array-question/17189 "2020-01-28T23:16:43Z")

</div>

For the past few days have been trying to better understand grids and arrays. After reading D Shiffman tutorial on 2D grid arrays I am now trying to play with that code a bit. I would like the grid(s) to appear twice,…

---

## [How can I run a for loop using a function?](https://discourse.processing.org/t/how-can-i-run-a-for-loop-using-a-function/17403)

<div class="topic-metadata">

**Author:** [@Daniele92](https://discourse.processing.org/u/Daniele92)\
**Replies:** 4\
**Last updated:** [January 28, 2020, 11:01pm UTC](https://discourse.processing.org/t/how-can-i-run-a-for-loop-using-a-function/17403 "2020-01-28T23:01:40Z")

</div>

Hello to everyone. Can someone explain to me , How can I run a : for( int i=100; i\>0; i=i-10 ) { ellipse(100,100,i,i); } Using a function?! Thank you , i DON’t want a code but need to understand for classroom activit…

---

## [Making a 3D camera](https://discourse.processing.org/t/making-a-3d-camera/17357)

<div class="topic-metadata">

**Author:** [@ArthusWQZ](https://discourse.processing.org/u/ArthusWQZ)\
**Replies:** 11\
**Last updated:** [January 28, 2020, 10:41pm UTC](https://discourse.processing.org/t/making-a-3d-camera/17357 "2020-01-28T22:41:12Z")

</div>

Hello everyone, I recently started coding a 3d program, some kind of game, but I remain stuck because of one simple thing : how to make a 3d camera ? In fact, the program generates a cube, but I want it to move when I …

---

## [New to processing, I need some help with classes](https://discourse.processing.org/t/new-to-processing-i-need-some-help-with-classes/17156)

<div class="topic-metadata">

**Author:** [@bugotc14](https://discourse.processing.org/u/bugotc14)\
**Replies:** 11\
**Last updated:** [January 28, 2020, 3:03pm UTC](https://discourse.processing.org/t/new-to-processing-i-need-some-help-with-classes/17156 "2020-01-28T15:03:16Z")

</div>

yesterday I tried to make a program that displays a cool ellipse with ellipses around it and I made it and everything worked fine, I made a class named DotsArray and made the ellipse array an object, I even added a feat…

---

## [Output to PDF every 5 Seconds](https://discourse.processing.org/t/output-to-pdf-every-5-seconds/17125)

<div class="topic-metadata">

**Author:** [@FutureDays](https://discourse.processing.org/u/FutureDays)\
**Replies:** 2\
**Last updated:** [January 21, 2020, 4:25pm UTC](https://discourse.processing.org/t/output-to-pdf-every-5-seconds/17125 "2020-01-21T16:25:28Z")

</div>

Hello, I am a total newbie to Processing but am loving the learning. I have a question, how do I write a line of code that outputs a PDF to a folder on the desktop every 5 seconds. I have placed my code here for refer…

---

## [Unable to write data in a text file](https://discourse.processing.org/t/unable-to-write-data-in-a-text-file/17374)

<div class="topic-metadata">

**Author:** [@iamgsshetty](https://discourse.processing.org/u/iamgsshetty)\
**Replies:** 2\
**Last updated:** [January 27, 2020, 2:43pm UTC](https://discourse.processing.org/t/unable-to-write-data-in-a-text-file/17374 "2020-01-27T14:43:55Z")

</div>

File getting created successfully but data is not getting written in file. code:- PrintWriter output; void setup() { // Create a new file in the sketch directory output = createWriter(“positions.txt”); } void draw…

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

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