# Coding Questions

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

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

**Page:** 31

---

## [How to animate the size of the rectangles](https://discourse.processing.org/t/how-to-animate-the-size-of-the-rectangles/36602)

<div class="topic-metadata">

**Author:** [@Alllukaht](https://discourse.processing.org/u/Alllukaht)\
**Replies:** 6\
**Last updated:** [April 26, 2022, 6:56pm UTC](https://discourse.processing.org/t/how-to-animate-the-size-of-the-rectangles/36602 "2022-04-26T18:56:22Z")

</div>

\< void setup() { size(800, 620); } void draw() { background(#000000); int lw = 40; fill(#fee445); noStroke(); for (int i = 20; i \< width; i += 60) { for (int j = 20; j \< height; j += 60) { if (dist(25, 25, mou…

---

## [Weird background stroke of a growing circle](https://discourse.processing.org/t/weird-background-stroke-of-a-growing-circle/36588)

<div class="topic-metadata">

**Author:** [@hannymymy](https://discourse.processing.org/u/hannymymy)\
**Replies:** 5\
**Last updated:** [April 25, 2022, 9:34pm UTC](https://discourse.processing.org/t/weird-background-stroke-of-a-growing-circle/36588 "2022-04-25T21:34:55Z")

</div>

Hello everyone! I’m very new to processing and have a few questions regarding this code: It is supposed to be a growing and a shrinking circle, and it works, but the background is such a weird black pattern, that I don’…

---

## [I can't make a single shader run in Processing](https://discourse.processing.org/t/i-cant-make-a-single-shader-run-in-processing/36462)

<div class="topic-metadata">

**Author:** [@Amirk](https://discourse.processing.org/u/Amirk)\
**Replies:** 6\
**Last updated:** [April 24, 2022, 5:19am UTC](https://discourse.processing.org/t/i-cant-make-a-single-shader-run-in-processing/36462 "2022-04-24T05:19:42Z")

</div>

Someone please help me to get a single shader working in Processing. I am not totally new to Processing, and I have created many shaders in Shadertoy. Now I would like to use shaders to make my simulations in Processing …

---

## [Problem with constructor](https://discourse.processing.org/t/problem-with-constructor/36566)

<div class="topic-metadata">

**Author:** [@RyanLovesPlanes](https://discourse.processing.org/u/RyanLovesPlanes)\
**Replies:** 1\
**Last updated:** [April 24, 2022, 4:48am UTC](https://discourse.processing.org/t/problem-with-constructor/36566 "2022-04-24T04:48:14Z")

</div>

hey ya’ll! My code is almost complete but I am having a problem with one of my classes not initializing a function I made. Specifically the “kill” function ( atarget.kill(); ). it says that kill() expects parameters like…

---

## [Rotating circle in 2D](https://discourse.processing.org/t/rotating-circle-in-2d/36538)

<div class="topic-metadata">

**Author:** [@Heavy](https://discourse.processing.org/u/Heavy)\
**Replies:** 10\
**Last updated:** [April 23, 2022, 8:55pm UTC](https://discourse.processing.org/t/rotating-circle-in-2d/36538 "2022-04-23T20:55:50Z")

</div>

Hello everyone, I am trying to make an algorithm that allows to simulate the rotating movement of a coin. The origin point to draw the coin must coincide with the center of the canvas (I must use the variables of the w…

---

## [Question on how to define a boolean](https://discourse.processing.org/t/question-on-how-to-define-a-boolean/36546)

<div class="topic-metadata">

**Author:** [@hannymymy](https://discourse.processing.org/u/hannymymy)\
**Replies:** 1\
**Last updated:** [April 23, 2022, 1:54pm UTC](https://discourse.processing.org/t/question-on-how-to-define-a-boolean/36546 "2022-04-23T13:54:08Z")

</div>

Hi, I am very new to coding and have a question regarding the code below. I’d like it to grow the circle with the count\_up, but when one of the circles reaches the max width to go back again (in a way to loop the action)…

---

## [Why NullPointerException](https://discourse.processing.org/t/why-nullpointerexception/36537)

<div class="topic-metadata">

**Author:** [@jiajia](https://discourse.processing.org/u/jiajia)\
**Replies:** 2\
**Last updated:** [April 23, 2022, 7:55am UTC](https://discourse.processing.org/t/why-nullpointerexception/36537 "2022-04-23T07:55:45Z")

</div>

import java.util.Iterator; ParticleSystem ps; Particle p; void setup(){ size(200,200); smooth(); ps = new ParticleSystem(new PVector(width/2,50)); } void draw(){ background(100); PVector gravity = new PVecto…

---

## [Grid using ramdomly some designs](https://discourse.processing.org/t/grid-using-ramdomly-some-designs/36205)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 10\
**Last updated:** [April 22, 2022, 2:12pm UTC](https://discourse.processing.org/t/grid-using-ramdomly-some-designs/36205 "2022-04-22T14:12:21Z")

</div>

Hi there! I am drawing a grid with 9 different types of design, as you can see in the Code Now, I would like to use them ramdomly, I mean, to fill the squares with them in a random way. How could I start doing that? Th…

---

## [Map random images to elements individually](https://discourse.processing.org/t/map-random-images-to-elements-individually/36022)

<div class="topic-metadata">

**Author:** [@oli7er](https://discourse.processing.org/u/oli7er)\
**Replies:** 4\
**Last updated:** [April 22, 2022, 10:44am UTC](https://discourse.processing.org/t/map-random-images-to-elements-individually/36022 "2022-04-22T10:44:56Z")

</div>

Hi everyone, I am trying to map randomly selected images to a trail of waving rectangles. Originally I had the pictures loaded through a for loop, which scrolled through the file names, but this looked too organised. So…

---

## [PShape createShape(GROUP) ignoring noStroke(), fill() when contained in PGraphics?](https://discourse.processing.org/t/pshape-createshape-group-ignoring-nostroke-fill-when-contained-in-pgraphics/36508)

<div class="topic-metadata">

**Author:** [@disuye](https://discourse.processing.org/u/disuye)\
**Replies:** 2\
**Last updated:** [April 22, 2022, 8:06am UTC](https://discourse.processing.org/t/pshape-createshape-group-ignoring-nostroke-fill-when-contained-in-pgraphics/36508 "2022-04-22T08:06:14Z")

</div>

Not sure if I’m missing something … I’m having trouble getting shapes (approx. 100 shapes, generated by a for loop in setup(), using the method .addChild() to create a group that is visible OK in draw()) to accept any st…

---

## [Displaying population data from a CSV file onto a map](https://discourse.processing.org/t/displaying-population-data-from-a-csv-file-onto-a-map/36505)

<div class="topic-metadata">

**Author:** [@JB77](https://discourse.processing.org/u/JB77)\
**Replies:** 2\
**Last updated:** [April 22, 2022, 5:40am UTC](https://discourse.processing.org/t/displaying-population-data-from-a-csv-file-onto-a-map/36505 "2022-04-22T05:40:46Z")

</div>

I am trying to plot population data (from three years) from a CSV file onto a map of the UK but am not sure how to do display the data, I have gathered the X and Y coordinates of each city in the CSV file, but I am not s…

---

## [Loop for same variable but opposite directions](https://discourse.processing.org/t/loop-for-same-variable-but-opposite-directions/36474)

<div class="topic-metadata">

**Author:** [@oli7er](https://discourse.processing.org/u/oli7er)\
**Replies:** 2\
**Last updated:** [April 20, 2022, 2:57pm UTC](https://discourse.processing.org/t/loop-for-same-variable-but-opposite-directions/36474 "2022-04-20T14:57:27Z")

</div>

Hi everyone, I have been using two loops to generate generate variables one of them going up from 0 - 360 and the other going in the opposite direction from 360 - 0. The code I have been using for this looks like this: …

---

## [Grid with random colors](https://discourse.processing.org/t/grid-with-random-colors/36469)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 2\
**Last updated:** [April 20, 2022, 9:40am UTC](https://discourse.processing.org/t/grid-with-random-colors/36469 "2022-04-20T09:40:13Z")

</div>

Hi there, I am trying to make a grid with random colors on every cell, but I only can change the color of every column and I don’t know why. Could you please help me? size(1000,1000); stroke(1); for(int x=0; …

---

## [Change window color - Processing 3](https://discourse.processing.org/t/change-window-color-processing-3/23422)

<div class="topic-metadata">

**Author:** [@Arnau](https://discourse.processing.org/u/Arnau)\
**Replies:** 1\
**Last updated:** [April 20, 2022, 12:52am UTC](https://discourse.processing.org/t/change-window-color-processing-3/23422 "2022-04-20T00:52:07Z")

</div>

There is anyway to change window decoration color / border color? I mean something like: surface.setDecorationColor(color(0, 0, 255)); or surface.setBorderColor(color(0, 0, 255)); But I need default window decoratio…

---

## [Game over screen not staying on the screen](https://discourse.processing.org/t/game-over-screen-not-staying-on-the-screen/36416)

<div class="topic-metadata">

**Author:** [@Bossinnit](https://discourse.processing.org/u/Bossinnit)\
**Replies:** 17\
**Last updated:** [April 19, 2022, 7:39pm UTC](https://discourse.processing.org/t/game-over-screen-not-staying-on-the-screen/36416 "2022-04-19T19:39:16Z")

</div>

I would appreciate it if someone could help me with my problem, I am trying to collide my character with the vehicle and then to display a “Game over” screen once it collides. The issue that i am facing is that when it c…

---

## [Problem with Game of Life](https://discourse.processing.org/t/problem-with-game-of-life/36407)

<div class="topic-metadata">

**Author:** [@paul3883](https://discourse.processing.org/u/paul3883)\
**Replies:** 5\
**Last updated:** [April 18, 2022, 5:33pm UTC](https://discourse.processing.org/t/problem-with-game-of-life/36407 "2022-04-18T17:33:06Z")

</div>

Hi there, I’ve decided to try programing the game of life with a little added covid implementation. I somehow have an issue which I think is in the “locating neighbors”. It seems to be working but somehow everything is …

---

## [Visual artefact issues with shapes with stroke() versus filled shapes](https://discourse.processing.org/t/visual-artefact-issues-with-shapes-with-stroke-versus-filled-shapes/36382)

<div class="topic-metadata">

**Author:** [@Misha.studio](https://discourse.processing.org/u/Misha.studio)\
**Replies:** 0\
**Last updated:** [April 16, 2022, 6:59pm UTC](https://discourse.processing.org/t/visual-artefact-issues-with-shapes-with-stroke-versus-filled-shapes/36382 "2022-04-16T18:59:35Z")

</div>

Hi! I’m working on a generative type project based on the Mexico Olympic type. When rendering my letters with strokes I find some visual artefacts - things simply don’t seem to align properly. When exported to .pdf or wh…

---

## [How to make two joysticks on a phone](https://discourse.processing.org/t/how-to-make-two-joysticks-on-a-phone/36374)

<div class="topic-metadata">

**Author:** [@urlxd](https://discourse.processing.org/u/urlxd)\
**Replies:** 0\
**Last updated:** [April 16, 2022, 9:33am UTC](https://discourse.processing.org/t/how-to-make-two-joysticks-on-a-phone/36374 "2022-04-16T09:33:29Z")

</div>

when I make two joysticks mouse X and Y need to be divided into 4 parts. If anyone knows how please tell me. code: Player player = new Player(100, 100); InterFace face; int mapWidth = 2000; int mapHeight = 2000; i…

---

## [Adding parameter of motion to FollowMe Program](https://discourse.processing.org/t/adding-parameter-of-motion-to-followme-program/36373)

<div class="topic-metadata">

**Author:** [@bking](https://discourse.processing.org/u/bking)\
**Replies:** 0\
**Last updated:** [April 16, 2022, 9:22am UTC](https://discourse.processing.org/t/adding-parameter-of-motion-to-followme-program/36373 "2022-04-16T09:22:47Z")

</div>

Hi Hi, I would like to transform this program so that the movement created with the mouse can be followed but slower than in reality. I would like to have this movement in slow motion, i.e. if I make some sort of circl…

---

## [Change background colour with a map](https://discourse.processing.org/t/change-background-colour-with-a-map/36370)

<div class="topic-metadata">

**Author:** [@hannymymy](https://discourse.processing.org/u/hannymymy)\
**Replies:** 4\
**Last updated:** [April 16, 2022, 10:46am UTC](https://discourse.processing.org/t/change-background-colour-with-a-map/36370 "2022-04-16T10:46:33Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hi everyone! I have a code where the abckground color right now changes ray values when I move my mouse. I want it to change in colour though, …

---

## [Why Always report errors](https://discourse.processing.org/t/why-always-report-errors/36342)

<div class="topic-metadata">

**Author:** [@jiajia](https://discourse.processing.org/u/jiajia)\
**Replies:** 2\
**Last updated:** [April 15, 2022, 11:05am UTC](https://discourse.processing.org/t/why-always-report-errors/36342 "2022-04-15T11:05:01Z")

</div>

please format code with \</\> button \* homework policy \* asking questions \</\>Mover movers = new Mover\[100\]; 液体; void setup（）{ size（640，320）; smooth（）; for（int i =0;i\<movers.length;i++）{ movers\[i\] = new Mover（rand…

---

## [Method to 'fill' a non rectangular shape with a pattern](https://discourse.processing.org/t/method-to-fill-a-non-rectangular-shape-with-a-pattern/35946)

<div class="topic-metadata">

**Author:** [@GoodJuJu](https://discourse.processing.org/u/GoodJuJu)\
**Replies:** 2\
**Last updated:** [April 14, 2022, 7:32pm UTC](https://discourse.processing.org/t/method-to-fill-a-non-rectangular-shape-with-a-pattern/35946 "2022-04-14T19:32:45Z")

</div>

I want to fill a non-rectangular shape with a pattern. Filling a rectangular shape is not a problem… all I need to do is to find the top left, bottom right coordinates and then not exceed them in my loop placing the pat…

---

## [StringList : sort by custom algorithm](https://discourse.processing.org/t/stringlist-sort-by-custom-algorithm/36312)

<div class="topic-metadata">

**Author:** [@f.damien12](https://discourse.processing.org/u/f.damien12)\
**Replies:** 4\
**Last updated:** [April 14, 2022, 7:45am UTC](https://discourse.processing.org/t/stringlist-sort-by-custom-algorithm/36312 "2022-04-14T07:45:21Z")

</div>

Hello In my sketch, a StringList stores some paths to files. I want to sort this StringList not by alphabetical order, but by file modification date. Is there a way to implement a custom sort algorithm ? Thanks.

---

## [Time as float values](https://discourse.processing.org/t/time-as-float-values/36327)

<div class="topic-metadata">

**Author:** [@arcadeperfect](https://discourse.processing.org/u/arcadeperfect)\
**Replies:** 3\
**Last updated:** [April 14, 2022, 6:45am UTC](https://discourse.processing.org/t/time-as-float-values/36327 "2022-04-14T06:45:46Z")

</div>

hello! I’m making an ‘analog’ clock, but I want the hands of the clock to move smoothly between values, rather than snapping to the int values returned by hour(), minute(), and second() I know I could implement somethi…

---

## [Pixel sorting an image with mouseMoved()](https://discourse.processing.org/t/pixel-sorting-an-image-with-mousemoved/36159)

<div class="topic-metadata">

**Author:** [@240garage](https://discourse.processing.org/u/240garage)\
**Replies:** 5\
**Last updated:** [April 13, 2022, 11:12pm UTC](https://discourse.processing.org/t/pixel-sorting-an-image-with-mousemoved/36159 "2022-04-13T23:12:21Z")

</div>

I am new to Processing and I found this code on the internet to pixel sort images. Now what I want to do is change the int brightnessValue when I move my mouse across the screen. The value needs to go from 240 to 0. How …

---

## [Increment within class](https://discourse.processing.org/t/increment-within-class/36261)

<div class="topic-metadata">

**Author:** [@Whell](https://discourse.processing.org/u/Whell)\
**Replies:** 5\
**Last updated:** [April 13, 2022, 11:40am UTC](https://discourse.processing.org/t/increment-within-class/36261 "2022-04-13T11:40:18Z")

</div>

Hi, i’m trying to draw a button as an exercise, with hover effect, this button i’m doing have a dot close to each corner of the button, on the outside and this dot is supposed to animate entering the button, the problem …

---

## [Coordinate ranges from CreateShape (customized shape)](https://discourse.processing.org/t/coordinate-ranges-from-createshape-customized-shape/36306)

<div class="topic-metadata">

**Author:** [@DianaG](https://discourse.processing.org/u/DianaG)\
**Replies:** 1\
**Last updated:** [April 12, 2022, 9:33pm UTC](https://discourse.processing.org/t/coordinate-ranges-from-createshape-customized-shape/36306 "2022-04-12T21:33:10Z")

</div>

Hello Everyone, I am trying to recreate a basic poster with some randomness on the triangles and arcs (on key pressed). The range in which the shapes can move is the full length of the screen’s width and height/2. Howe…

---

## [Reset by pressing key](https://discourse.processing.org/t/reset-by-pressing-key/35953)

<div class="topic-metadata">

**Author:** [@DomH](https://discourse.processing.org/u/DomH)\
**Replies:** 2\
**Last updated:** [April 12, 2022, 3:30pm UTC](https://discourse.processing.org/t/reset-by-pressing-key/35953 "2022-04-12T15:30:38Z")

</div>

Hello, I am trying to reset my canvas if pressing a key but cannot get it to work. Any ideas? int boxsize = 80; int cols, rows; ArrayList\<Box\> boxes = new ArrayList\<Box\>(); Box active; public enum Shape { TRIANGLE, …

---

## [How to load the PNG spritesheet properly? (Processing 3.5.4)](https://discourse.processing.org/t/how-to-load-the-png-spritesheet-properly-processing-3-5-4/35190)

<div class="topic-metadata">

**Author:** [@RafaDuarte](https://discourse.processing.org/u/RafaDuarte)\
**Replies:** 3\
**Last updated:** [April 12, 2022, 2:47pm UTC](https://discourse.processing.org/t/how-to-load-the-png-spritesheet-properly-processing-3-5-4/35190 "2022-04-12T14:47:20Z")

</div>

I have been coding a simple 2D game in Processing 3.5.4 for university purposes, however I’m stuck in the part in which I should make the PNG spritesheet load in screen with all its colours and moves. What I see when I r…

---

## [Find new Destination Point (rotate PVector)](https://discourse.processing.org/t/find-new-destination-point-rotate-pvector/22585)

<div class="topic-metadata">

**Author:** [@vjjv](https://discourse.processing.org/u/vjjv)\
**Replies:** 4\
**Last updated:** [April 12, 2022, 8:37am UTC](https://discourse.processing.org/t/find-new-destination-point-rotate-pvector/22585 "2022-04-12T08:37:10Z")

</div>

Hi everyone. I ve this silly problem that i cant figure out. Im creating an object that has an origin point and destination point. When i create a new object, i swap the coordinate and the destination vector is now the…

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

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