# Coding Questions

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

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

**Page:** 86

---

## [Change background in order/ using values in array](https://discourse.processing.org/t/change-background-in-order-using-values-in-array/22665)

<div class="topic-metadata">

**Author:** [@anderbaer](https://discourse.processing.org/u/anderbaer)\
**Replies:** 5\
**Last updated:** [July 16, 2020, 8:29pm UTC](https://discourse.processing.org/t/change-background-in-order-using-values-in-array/22665 "2020-07-16T20:29:35Z")

</div>

int i = 0; int\[\] array = {250, 150, 100, 50, 0}; void setup() { size(500, 500); } void draw() { for (int i = 0; i \< array.length; i++) { if (array\[i\] == 0) { println(array); background(array\[i…

---

## [Objects moving at the same time](https://discourse.processing.org/t/objects-moving-at-the-same-time/22640)

<div class="topic-metadata">

**Author:** [@luimi](https://discourse.processing.org/u/luimi)\
**Replies:** 2\
**Last updated:** [July 16, 2020, 4:08pm UTC](https://discourse.processing.org/t/objects-moving-at-the-same-time/22640 "2020-07-16T16:08:33Z")

</div>

hi, i have made a random walker proggram and my goal is to be able to have a walker appear on the mouse position with every mouse click, but when a new one appears the previous one always stops moving, please help me. so…

---

## [Trying to make something like a visual novel with a lot of booleans](https://discourse.processing.org/t/trying-to-make-something-like-a-visual-novel-with-a-lot-of-booleans/22633)

<div class="topic-metadata">

**Author:** [@qewer3322](https://discourse.processing.org/u/qewer3322)\
**Replies:** 7\
**Last updated:** [July 16, 2020, 11:47am UTC](https://discourse.processing.org/t/trying-to-make-something-like-a-visual-novel-with-a-lot-of-booleans/22633 "2020-07-16T11:47:27Z")

</div>

I’m trying to make something like a visual novel game but without choices (but there will be other interactive stuff of course). I decided to use booleans for scenes like this: boolean s1 = true; boolean s2 = false; boo…

---

## [How to edit the path of an SVG using the code](https://discourse.processing.org/t/how-to-edit-the-path-of-an-svg-using-the-code/22604)

<div class="topic-metadata">

**Author:** [@DeathEater](https://discourse.processing.org/u/DeathEater)\
**Replies:** 1\
**Last updated:** [July 15, 2020, 3:10pm UTC](https://discourse.processing.org/t/how-to-edit-the-path-of-an-svg-using-the-code/22604 "2020-07-15T15:10:19Z")

</div>

In the path of an SVG file \<path id =“12121”, fill=“FF0000”…\>. How to get the attributes inside the path and edit any specific attribute. For example, if i want to change the color of that path for any selected ids. how …

---

## [Sequence of actions from array](https://discourse.processing.org/t/sequence-of-actions-from-array/22480)

<div class="topic-metadata">

**Author:** [@LordCacops](https://discourse.processing.org/u/LordCacops)\
**Replies:** 5\
**Last updated:** [July 14, 2020, 10:14pm UTC](https://discourse.processing.org/t/sequence-of-actions-from-array/22480 "2020-07-14T22:14:54Z")

</div>

Howdy! I want to create a sequence of events as determined by an array, but for some reason, only the last element of the array is accounted for. Also, I would like the actions to occur with a slight delay with respect…

---

## [About Restarting](https://discourse.processing.org/t/about-restarting/22557)

<div class="topic-metadata">

**Author:** [@SouSageYa](https://discourse.processing.org/u/SouSageYa)\
**Replies:** 2\
**Last updated:** [July 14, 2020, 9:42pm UTC](https://discourse.processing.org/t/about-restarting/22557 "2020-07-14T21:42:40Z")

</div>

Can I write a Reset code for my sketch. Like the Stop and Run method

---

## [Struggling to find cause of mouseX shifting to the right when used](https://discourse.processing.org/t/struggling-to-find-cause-of-mousex-shifting-to-the-right-when-used/22602)

<div class="topic-metadata">

**Author:** [@falseStart](https://discourse.processing.org/u/falseStart)\
**Replies:** 7\
**Last updated:** [July 14, 2020, 8:38pm UTC](https://discourse.processing.org/t/struggling-to-find-cause-of-mousex-shifting-to-the-right-when-used/22602 "2020-07-14T20:38:03Z")

</div>

I’m currently trying to make a program that shows a grid of tiles that change color when clicked. I’ve made it so that the tiles are evenly distributed with an edge or gutter around the sides no matter the number of tile…

---

## [ArrayList function add doesn't work](https://discourse.processing.org/t/arraylist-function-add-doesnt-work/22359)

<div class="topic-metadata">

**Author:** [@Kai](https://discourse.processing.org/u/Kai)\
**Replies:** 10\
**Last updated:** [July 5, 2020, 5:08am UTC](https://discourse.processing.org/t/arraylist-function-add-doesnt-work/22359 "2020-07-05T05:08:52Z")

</div>

Hello guys, I’m new to processing and have been recently following some youtube online tutorials to learn. The topic is called ArrayList. However, when I followed the scripts some errors occurred, suggesting"The functi…

---

## [Why is this keyPressed not working](https://discourse.processing.org/t/why-is-this-keypressed-not-working/22603)

<div class="topic-metadata">

**Author:** [@DeathEater](https://discourse.processing.org/u/DeathEater)\
**Replies:** 5\
**Last updated:** [July 14, 2020, 12:35pm UTC](https://discourse.processing.org/t/why-is-this-keypressed-not-working/22603 "2020-07-14T12:35:49Z")

</div>

Inside the draw function i made a keyPressed. I want that piece of code to run only if i press r, but for some reason it is not working. Is there a better way to do it. I also want to put multiple different keys to run d…

---

## [Splitting a String into an Array](https://discourse.processing.org/t/splitting-a-string-into-an-array/22495)

<div class="topic-metadata">

**Author:** [@CKMJPEG](https://discourse.processing.org/u/CKMJPEG)\
**Replies:** 8\
**Last updated:** [July 14, 2020, 1:53am UTC](https://discourse.processing.org/t/splitting-a-string-into-an-array/22495 "2020-07-14T01:53:31Z")

</div>

Hi Processing friends, I have a string .txt file that has 6 columns of data, which corresponds to x,y,z,r,g,b I want to load the string file and parse the data into an array. I would like to have the data as an array …

---

## [Rotate png in 90 degree](https://discourse.processing.org/t/rotate-png-in-90-degree/22492)

<div class="topic-metadata">

**Author:** [@aerob](https://discourse.processing.org/u/aerob)\
**Replies:** 6\
**Last updated:** [July 13, 2020, 2:38pm UTC](https://discourse.processing.org/t/rotate-png-in-90-degree/22492 "2020-07-13T14:38:42Z")

</div>

Hello guys, I am very short on time and new to processing but i need help on fixing my code. I have a large screen filled with a png. It looks like this: my goal is that they all spin every second for random 90-180 or…

---

## [Mapping with set values](https://discourse.processing.org/t/mapping-with-set-values/22586)

<div class="topic-metadata">

**Author:** [@yorkie](https://discourse.processing.org/u/yorkie)\
**Replies:** 3\
**Last updated:** [July 13, 2020, 7:40am UTC](https://discourse.processing.org/t/mapping-with-set-values/22586 "2020-07-13T07:40:54Z")

</div>

Hi There, I hope one of you fine people can help be with a problem. I need to map a range a values, however my range is non linear. A few example values below. 23=8 22=15 21=19 20=20 19=22 18=23 About 4 years ag…

---

## [Map csv file data in a map of any country](https://discourse.processing.org/t/map-csv-file-data-in-a-map-of-any-country/22565)

<div class="topic-metadata">

**Author:** [@DeathEater](https://discourse.processing.org/u/DeathEater)\
**Replies:** 1\
**Last updated:** [July 13, 2020, 5:57am UTC](https://discourse.processing.org/t/map-csv-file-data-in-a-map-of-any-country/22565 "2020-07-13T05:57:57Z")

</div>

Hello guys , I am new to processing and I have a question about my program. I am planning to plot the Corona virus data in the map of Nepal. I have a SVG file for the map, and csv files for corona virus data and Latitud…

---

## [Volumetric visualizations from X-ray micro-CT datasets(s) in Processing 3.53](https://discourse.processing.org/t/volumetric-visualizations-from-x-ray-micro-ct-datasets-s-in-processing-3-53/22511)

<div class="topic-metadata">

**Author:** [@JSGauthier](https://discourse.processing.org/u/JSGauthier)\
**Replies:** 8\
**Last updated:** [July 10, 2020, 6:49pm UTC](https://discourse.processing.org/t/volumetric-visualizations-from-x-ray-micro-ct-datasets-s-in-processing-3-53/22511 "2020-07-10T18:49:23Z")

</div>

Hello, my name is JS Gauthier. I am a artist working with scientific datasets in Saskatoon, Canada (https://vimeo.com/jsgauthier or https://jsgauthier.com/ ). I have created a series of 3D scans using X-Ray micro-tomogra…

---

## [Access SVG file path ID for plotting data into it](https://discourse.processing.org/t/access-svg-file-path-id-for-plotting-data-into-it/22572)

<div class="topic-metadata">

**Author:** [@DeathEater](https://discourse.processing.org/u/DeathEater)\
**Replies:** 1\
**Last updated:** [July 12, 2020, 6:42pm UTC](https://discourse.processing.org/t/access-svg-file-path-id-for-plotting-data-into-it/22572 "2020-07-12T18:42:38Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I have SVG file ( Map of Nepal). The map has 75 districts. The path has an id which is the same name as the district. As as example see the code…

---

## [About text() function](https://discourse.processing.org/t/about-text-function/22440)

<div class="topic-metadata">

**Author:** [@SouSageYa](https://discourse.processing.org/u/SouSageYa)\
**Replies:** 7\
**Last updated:** [July 11, 2020, 8:15pm UTC](https://discourse.processing.org/t/about-text-function/22440 "2020-07-11T20:15:24Z")

</div>

//Pressure Chart Value fill(#D6CDCD); stroke(#000000); rect(260,325,200,40,50); fill(#FF301E); text(f\[7\],340,110); //Height Chart Value fill(#D6CDCD); stroke(#000000); rect(260,285,200,40,50); fill(#FF301E); text(f\[8\]…

---

## [Coding problem NullPointerException](https://discourse.processing.org/t/coding-problem-nullpointerexception/22551)

<div class="topic-metadata">

**Author:** [@christiank79](https://discourse.processing.org/u/christiank79)\
**Replies:** 4\
**Last updated:** [July 11, 2020, 5:56pm UTC](https://discourse.processing.org/t/coding-problem-nullpointerexception/22551 "2020-07-11T17:56:55Z")

</div>

I write a code who change a picture in Dithering,but show me a NullPointerException (line 16) What can I do? I have update Processing 3.5.4: This is coding: //variable to store image import processing.svg.\*; PImage th…

---

## [How to cube a sine/cosine function in processing](https://discourse.processing.org/t/how-to-cube-a-sine-cosine-function-in-processing/17257)

<div class="topic-metadata">

**Author:** [@prathmesh](https://discourse.processing.org/u/prathmesh)\
**Replies:** 25\
**Last updated:** [July 11, 2020, 7:16pm UTC](https://discourse.processing.org/t/how-to-cube-a-sine-cosine-function-in-processing/17257 "2020-07-11T19:16:31Z")

</div>

Hello, How do I write cos"raised to the power 3"(t) in my processing code? I am trying to write this equation : Thanks :smiley:

---

## [Finding the angle of an arc?](https://discourse.processing.org/t/finding-the-angle-of-an-arc/22543)

<div class="topic-metadata">

**Author:** [@rkdnson](https://discourse.processing.org/u/rkdnson)\
**Replies:** 3\
**Last updated:** [July 11, 2020, 12:21pm UTC](https://discourse.processing.org/t/finding-the-angle-of-an-arc/22543 "2020-07-11T12:21:54Z")

</div>

Hello, please excuse my crude drawing. I am looking to constrain the amount a circle rotates on the circumference of its parent circle. I have the center of both, and I already have a function that moves it around the an…

---

## [HELP. How can I intersect three colors from these ellipses?](https://discourse.processing.org/t/help-how-can-i-intersect-three-colors-from-these-ellipses/22500)

<div class="topic-metadata">

**Author:** [@johncusack](https://discourse.processing.org/u/johncusack)\
**Replies:** 2\
**Last updated:** [July 10, 2020, 1:17pm UTC](https://discourse.processing.org/t/help-how-can-i-intersect-three-colors-from-these-ellipses/22500 "2020-07-10T13:17:49Z")

</div>

Hello! I need some help with this sketch. I’m trying to draw this shape filled with three different colors, in tree different vertex. I’m thinking I need to draw three ellipses of different colors, then they intersect wi…

---

## [Displaying PShapes](https://discourse.processing.org/t/displaying-pshapes/7686)

<div class="topic-metadata">

**Author:** [@stirman](https://discourse.processing.org/u/stirman)\
**Replies:** 4\
**Last updated:** [July 10, 2020, 12:48pm UTC](https://discourse.processing.org/t/displaying-pshapes/7686 "2020-07-10T12:48:42Z")

</div>

As part of my larger Scribble Portrait series, I’m trying to make all the scribbles shapes that I can add as children to a parent shape, to manipulate them all together after they’ve been drawn. I’m having trouble gettin…

---

## [Help with classes and hexagon](https://discourse.processing.org/t/help-with-classes-and-hexagon/22510)

<div class="topic-metadata">

**Author:** [@jensemand](https://discourse.processing.org/u/jensemand)\
**Replies:** 2\
**Last updated:** [July 9, 2020, 6:04pm UTC](https://discourse.processing.org/t/help-with-classes-and-hexagon/22510 "2020-07-09T18:04:01Z")

</div>

Hi I have tried to make a hexagon by using vectors however when I try to put the shape into a class (so I later can make a grid where I can detect in which one my mouse is in) but the problem is I can’t display my shape.…

---

## [Sort PImage array by brightness](https://discourse.processing.org/t/sort-pimage-array-by-brightness/19423)

<div class="topic-metadata">

**Author:** [@TimoL](https://discourse.processing.org/u/TimoL)\
**Replies:** 6\
**Last updated:** [July 9, 2020, 6:12am UTC](https://discourse.processing.org/t/sort-pimage-array-by-brightness/19423 "2020-07-09T06:12:23Z")

</div>

Hi there, I have an array of say 10 images and I’m trying to re-order their indexing based on the overall brightness of each image. Darkest image is 0 & brightest is 10. I then want to save out each image with its new…

---

## [Math with map() to get rising and falling numbers from an increasing value](https://discourse.processing.org/t/math-with-map-to-get-rising-and-falling-numbers-from-an-increasing-value/22467)

<div class="topic-metadata">

**Author:** [@Ackados](https://discourse.processing.org/u/Ackados)\
**Replies:** 3\
**Last updated:** [July 8, 2020, 6:37pm UTC](https://discourse.processing.org/t/math-with-map-to-get-rising-and-falling-numbers-from-an-increasing-value/22467 "2020-07-08T18:37:36Z")

</div>

I have an interesting math and coding question. I had no idea how to explain this in just the title. I have int iValue = 0; and every second, iValue increases by one. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1…

---

## [Making multiple images rotate in a circle](https://discourse.processing.org/t/making-multiple-images-rotate-in-a-circle/17795)

<div class="topic-metadata">

**Author:** [@Alexsmithson](https://discourse.processing.org/u/Alexsmithson)\
**Replies:** 6\
**Last updated:** [July 8, 2020, 2:13pm UTC](https://discourse.processing.org/t/making-multiple-images-rotate-in-a-circle/17795 "2020-07-08T14:13:52Z")

</div>

I NEED HELP FROM THE PROCESSING GODS! i need to make multiple images rotate in a circular shape so it fits with the lines of text. so far i have these lines of code, and i need to make the images rotate in the same fash…

---

## [Resize window and object in class](https://discourse.processing.org/t/resize-window-and-object-in-class/22448)

<div class="topic-metadata">

**Author:** [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Replies:** 4\
**Last updated:** [July 8, 2020, 7:32am UTC](https://discourse.processing.org/t/resize-window-and-object-in-class/22448 "2020-07-08T07:32:38Z")

</div>

Hi all, I am trying to do a small GUI and I was playing with resize. So, the following sketch display’s two circles as if they were two LEDs. I start the sketch with a small window, but if I change the window size to f…

---

## [Draw every possible unique combination of a 3x3 circle grid with two colors](https://discourse.processing.org/t/draw-every-possible-unique-combination-of-a-3x3-circle-grid-with-two-colors/22338)

<div class="topic-metadata">

**Author:** [@whistlinpete](https://discourse.processing.org/u/whistlinpete)\
**Replies:** 23\
**Last updated:** [July 7, 2020, 5:47pm UTC](https://discourse.processing.org/t/draw-every-possible-unique-combination-of-a-3x3-circle-grid-with-two-colors/22338 "2020-07-07T17:47:13Z")

</div>

Hi, I’m a designer trying to draw every possible combination of a 3x3 circle grid with two colors. Here’s a example: But this is an even better example of what I’m trying to do. I know there are 512 different possibi…

---

## [Jagged lines appearing in animating sine wave variation code](https://discourse.processing.org/t/jagged-lines-appearing-in-animating-sine-wave-variation-code/22218)

<div class="topic-metadata">

**Author:** [@Ruchi](https://discourse.processing.org/u/Ruchi)\
**Replies:** 3\
**Last updated:** [July 7, 2020, 11:47am UTC](https://discourse.processing.org/t/jagged-lines-appearing-in-animating-sine-wave-variation-code/22218 "2020-07-07T11:47:06Z")

</div>

Wave w; int noW = 5; // No. of Waves on either side of half period int totalwaves = (noW\*2)-1; float freq = 1; // How many repetitions float period; boolean inverse; void setup() { size(800, 800); background(0); …

---

## [Cannot call circle() in seperate java file](https://discourse.processing.org/t/cannot-call-circle-in-seperate-java-file/22439)

<div class="topic-metadata">

**Author:** [@Ackados](https://discourse.processing.org/u/Ackados)\
**Replies:** 1\
**Last updated:** [July 7, 2020, 6:17am UTC](https://discourse.processing.org/t/cannot-call-circle-in-seperate-java-file/22439 "2020-07-07T06:17:40Z")

</div>

I got my sketch.java file, and I can call circle(100, 100, 10); just fine in there. However, when I go to my Particle.java, I call circle(100, 100, 10);, I get errors. First, this is my import: import processing.core.\*; …

---

## [Iterate once and only once through all the possible configurations of an array](https://discourse.processing.org/t/iterate-once-and-only-once-through-all-the-possible-configurations-of-an-array/22366)

<div class="topic-metadata">

**Author:** [@whistlinpete](https://discourse.processing.org/u/whistlinpete)\
**Replies:** 18\
**Last updated:** [July 6, 2020, 4:10pm UTC](https://discourse.processing.org/t/iterate-once-and-only-once-through-all-the-possible-configurations-of-an-array/22366 "2020-07-06T16:10:53Z")

</div>

I am trying to create a program that will iterate through all the possible combinations for a given array once and only once, and use those combinations to color a grid of dots. I’ve simplified the problem to a one-row, …

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

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