# Coding Questions

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

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

**Page:** 116

---

## [How to add image to particle system](https://discourse.processing.org/t/how-to-add-image-to-particle-system/16017)

<div class="topic-metadata">

**Author:** [@dawn](https://discourse.processing.org/u/dawn)\
**Replies:** 5\
**Last updated:** [December 11, 2019, 2:23pm UTC](https://discourse.processing.org/t/how-to-add-image-to-particle-system/16017 "2019-12-11T14:23:11Z")

</div>

PImage fondo; Globos\[\] globos = new Globos\[0\]; int cantGlobos =400; void setup () { size (900, 606); noStroke(); smooth(); fondo=loadImage ("fondoperdiste.jpg"); } void draw() { background(fondo); globos = (Globo…

---

## [Degradado Lineal Diagonal](https://discourse.processing.org/t/degradado-lineal-diagonal/16298)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 7\
**Last updated:** [December 11, 2019, 12:04am UTC](https://discourse.processing.org/t/degradado-lineal-diagonal/16298 "2019-12-11T00:04:29Z")

</div>

Hi! How could I change this linear gradient from horizontal to diagonal? Thanks! void setup(){ size(360,720); smooth(); background(255,95,95); float l = width/255; for(int i = 0; i\<width; i++) { stroke(2…

---

## [Dirección agujas reloj](https://discourse.processing.org/t/direccion-agujas-reloj/16277)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 8\
**Last updated:** [December 10, 2019, 7:49pm UTC](https://discourse.processing.org/t/direccion-agujas-reloj/16277 "2019-12-10T19:49:42Z")

</div>

¡Hola! Necesito realizar varios cambios en el siguiente reloj, ¿podéis ayudarme? ¿Cómo puedo conseguir que la aguja vaya hacia atrás, es decir, que se mueva en la dirección contraria a las agujas del reloj? ¿Cómo …

---

## [How to add sliders to fluid animation](https://discourse.processing.org/t/how-to-add-sliders-to-fluid-animation/16291)

<div class="topic-metadata">

**Author:** [@fabnai](https://discourse.processing.org/u/fabnai)\
**Replies:** 1\
**Last updated:** [December 10, 2019, 11:36am UTC](https://discourse.processing.org/t/how-to-add-sliders-to-fluid-animation/16291 "2019-12-10T11:36:30Z")

</div>

Hello everybody I am new to processing and coding in general so please have patience with me. I found a tutorial from coding train on how to create fluid animations in processing. I would like to control different par…

---

## [Embedding .pde to html does not work/ .pde to p5.js](https://discourse.processing.org/t/embedding-pde-to-html-does-not-work-pde-to-p5-js/16181)

<div class="topic-metadata">

**Author:** [@hannes](https://discourse.processing.org/u/hannes)\
**Replies:** 6\
**Last updated:** [December 9, 2019, 8:38am UTC](https://discourse.processing.org/t/embedding-pde-to-html-does-not-work-pde-to-p5-js/16181 "2019-12-09T08:38:31Z")

</div>

Hello y’all, im trying to embed a processing sketch I just made in html but it didn’t work. I read some manuals on this and others forum but Im doing something wrong. (like this article: http://processingjs.org/articles…

---

## [Trouble with shapes](https://discourse.processing.org/t/trouble-with-shapes/16243)

<div class="topic-metadata">

**Author:** [@FurryNightShade](https://discourse.processing.org/u/FurryNightShade)\
**Replies:** 3\
**Last updated:** [December 9, 2019, 4:18am UTC](https://discourse.processing.org/t/trouble-with-shapes/16243 "2019-12-09T04:18:20Z")

</div>

Hi. I’m having some trouble with drawing shapes. I’m trying to draw a B and it doesn’t fill the whole shape. Acording to the example on the beginContour() doc page, you don’t have to draw the starting point at the end,…

---

## [How to add curvature on a recursive tree](https://discourse.processing.org/t/how-to-add-curvature-on-a-recursive-tree/16257)

<div class="topic-metadata">

**Author:** [@marcoo](https://discourse.processing.org/u/marcoo)\
**Replies:** 1\
**Last updated:** [December 9, 2019, 3:47am UTC](https://discourse.processing.org/t/how-to-add-curvature-on-a-recursive-tree/16257 "2019-12-09T03:47:39Z")

</div>

Hi there. I’m doing a sketch of a recursive tree in processing and i want to add curvature on the branches but i don’t know how… There is the code below. float minBranchLen = 0.5; float angle= radians (30); float bran…

---

## [How to fade an image to black over time](https://discourse.processing.org/t/how-to-fade-an-image-to-black-over-time/16100)

<div class="topic-metadata">

**Author:** [@pw00](https://discourse.processing.org/u/pw00)\
**Replies:** 7\
**Last updated:** [December 9, 2019, 12:28am UTC](https://discourse.processing.org/t/how-to-fade-an-image-to-black-over-time/16100 "2019-12-09T00:28:08Z")

</div>

I’m a beginner in processing and overall coding, so I’m not really sure what and how I’m supposed to do certain things. Is there a way to fade out an image to black over time or use a tint to make an image black over tim…

---

## ["wait until" syntax?](https://discourse.processing.org/t/wait-until-syntax/15838)

<div class="topic-metadata">

**Author:** [@benross](https://discourse.processing.org/u/benross)\
**Replies:** 6\
**Last updated:** [December 8, 2019, 7:46pm UTC](https://discourse.processing.org/t/wait-until-syntax/15838 "2019-12-08T19:46:12Z")

</div>

Hi all - is there any way I can make some section of code in draw() only after a certain event has happened? For example can I only start drawing things after a mouseclick or if the user presses a set key? Thanks in ad…

---

## [Closing a second window](https://discourse.processing.org/t/closing-a-second-window/381)

<div class="topic-metadata">

**Author:** [@lmccandless](https://discourse.processing.org/u/lmccandless)\
**Replies:** 17\
**Last updated:** [December 8, 2019, 9:19pm UTC](https://discourse.processing.org/t/closing-a-second-window/381 "2019-12-08T21:19:10Z")

</div>

I want to be able to create a second window. The problem is I want the user to be able to close the second window, but doing so closes both the second and main frame. Is there a way I can prevent this? PWindow win; pub…

---

## [Preventing Keypress from continuously activating](https://discourse.processing.org/t/preventing-keypress-from-continuously-activating/16241)

<div class="topic-metadata">

**Author:** [@Kitty](https://discourse.processing.org/u/Kitty)\
**Replies:** 3\
**Last updated:** [December 8, 2019, 8:56pm UTC](https://discourse.processing.org/t/preventing-keypress-from-continuously-activating/16241 "2019-12-08T20:56:10Z")

</div>

I have my code for keypress here. What I’m looking for is a way to prevent the code from jumping straight from “isGameStart” to “isGameS1”. So that it requires you to hit the ENTER key again. void keyReleased() { if (ke…

---

## [Can I interrupt a closing of a sketch to save data?](https://discourse.processing.org/t/can-i-interrupt-a-closing-of-a-sketch-to-save-data/16231)

<div class="topic-metadata">

**Author:** [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Replies:** 8\
**Last updated:** [December 8, 2019, 8:46pm UTC](https://discourse.processing.org/t/can-i-interrupt-a-closing-of-a-sketch-to-save-data/16231 "2019-12-08T20:46:35Z")

</div>

Hello all, Can I interrupt a closing of a sketch to save data? When Alt-F4 is pressed or the cross in the window is clicked (OS = Windows), the program closes. I would like to interrupt this, to save a file that the u…

---

## [Can you help me optimise this code?](https://discourse.processing.org/t/can-you-help-me-optimise-this-code/16251)

<div class="topic-metadata">

**Author:** [@yes](https://discourse.processing.org/u/yes)\
**Replies:** 4\
**Last updated:** [December 8, 2019, 7:01pm UTC](https://discourse.processing.org/t/can-you-help-me-optimise-this-code/16251 "2019-12-08T19:01:49Z")

</div>

I need help optimising this code: String ROMNAME = str(char(bytes\[308\]))+str(char(bytes\[309\]))+str(char(bytes\[310\]))+str(char(bytes\[311\]))+str(char(bytes\[312\]))+str(char(bytes\[313\]))+str(char(bytes\[314\]))+str(char(bytes…

---

## [Solar system simulations and the Hohmann transfer orbit](https://discourse.processing.org/t/solar-system-simulations-and-the-hohmann-transfer-orbit/16242)

<div class="topic-metadata">

**Author:** [@O-O](https://discourse.processing.org/u/O-O)\
**Replies:** 1\
**Last updated:** [December 8, 2019, 12:03pm UTC](https://discourse.processing.org/t/solar-system-simulations-and-the-hohmann-transfer-orbit/16242 "2019-12-08T12:03:18Z")

</div>

import java.text.SimpleDateFormat; import java.util.Date; //======================================================================================== float eccentricity\[\] = {0,0.205,0.007,0.017,0.094,0.049,0.057,0.046,0.0…

---

## [Why do I need to swap x with y?](https://discourse.processing.org/t/why-do-i-need-to-swap-x-with-y/16227)

<div class="topic-metadata">

**Author:** [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Replies:** 4\
**Last updated:** [December 8, 2019, 11:44am UTC](https://discourse.processing.org/t/why-do-i-need-to-swap-x-with-y/16227 "2019-12-08T11:44:48Z")

</div>

I made a script where I can interpolate between the corners of a quad to get a grid of points. First off all, I have a light headache, so maybe I understand it tomorrow. Why do I need to swap x and y to make the code…

---

## [Ellipse/circle clipping mask in 3d text output](https://discourse.processing.org/t/ellipse-circle-clipping-mask-in-3d-text-output/16193)

<div class="topic-metadata">

**Author:** [@add02one](https://discourse.processing.org/u/add02one)\
**Replies:** 1\
**Last updated:** [December 8, 2019, 5:21am UTC](https://discourse.processing.org/t/ellipse-circle-clipping-mask-in-3d-text-output/16193 "2019-12-08T05:21:28Z")

</div>

hi, I’m working on a project where text is output in 3d renderer rotating around various axis and moving across. Below is the simplified version. It uses rectangular mask through clip(), but i can’t find a way to make it…

---

## [Random Crashes and Unresponsive System](https://discourse.processing.org/t/random-crashes-and-unresponsive-system/16207)

<div class="topic-metadata">

**Author:** [@Fin](https://discourse.processing.org/u/Fin)\
**Replies:** 1\
**Last updated:** [December 8, 2019, 4:13am UTC](https://discourse.processing.org/t/random-crashes-and-unresponsive-system/16207 "2019-12-08T04:13:30Z")

</div>

I’m trying to make a game where you move in a 3D environment and a minor issue has appeared. Occasionally when I try to run my program it gives the error “Exception in thread “AWT-EventQueue-0” java.lang.OutOfMemoryError…

---

## [How can I sort JSON by ID?](https://discourse.processing.org/t/how-can-i-sort-json-by-id/15924)

<div class="topic-metadata">

**Author:** [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Replies:** 22\
**Last updated:** [December 8, 2019, 12:46am UTC](https://discourse.processing.org/t/how-can-i-sort-json-by-id/15924 "2019-12-08T00:46:23Z")

</div>

Hello all, I am working on a complex JSON file. I load the entire file (list of items A and each item has different JSON-Arrays and JSON-Objects in it). I don’t copy it into an Array of a class but just work with the …

---

## [Is there a way to make events happen at specific times?](https://discourse.processing.org/t/is-there-a-way-to-make-events-happen-at-specific-times/16211)

<div class="topic-metadata">

**Author:** [@pw00](https://discourse.processing.org/u/pw00)\
**Replies:** 10\
**Last updated:** [December 7, 2019, 4:14pm UTC](https://discourse.processing.org/t/is-there-a-way-to-make-events-happen-at-specific-times/16211 "2019-12-07T16:14:03Z")

</div>

I’m trying make it seem like a certain portion of an image “rots” (by using tint) after a certain time to show the decomposition rates of different types of recyclables and what not, but I can’t seem to find any tutorial…

---

## [Question about mousePressed](https://discourse.processing.org/t/question-about-mousepressed/16142)

<div class="topic-metadata">

**Author:** [@pw00](https://discourse.processing.org/u/pw00)\
**Replies:** 10\
**Last updated:** [December 7, 2019, 12:10pm UTC](https://discourse.processing.org/t/question-about-mousepressed/16142 "2019-12-07T12:10:33Z")

</div>

So I’m trying to figure out how to make one of my images appear and stay ON SCREEN with mousePressed, but it always goes away. Is there a way I can make it stay on screen? (I’ve also tried to do the same with mouseClicke…

---

## [Textures with beginContour](https://discourse.processing.org/t/textures-with-begincontour/16206)

<div class="topic-metadata">

**Author:** [@Fin](https://discourse.processing.org/u/Fin)\
**Replies:** 0\
**Last updated:** [December 7, 2019, 7:38am UTC](https://discourse.processing.org/t/textures-with-begincontour/16206 "2019-12-07T07:38:37Z")

</div>

I created a plane with a texture applied and it worked fine. I tried adding a hole in the centre using the beginContour(); function, but doing this however seemed to frick up the textures and I’m not sure how to fix them…

---

## [Minesweeper Game Function Help](https://discourse.processing.org/t/minesweeper-game-function-help/16126)

<div class="topic-metadata">

**Author:** [@IsaiahZ](https://discourse.processing.org/u/IsaiahZ)\
**Replies:** 8\
**Last updated:** [December 7, 2019, 5:38am UTC](https://discourse.processing.org/t/minesweeper-game-function-help/16126 "2019-12-07T05:38:20Z")

</div>

Hi all, I’m attempting to make a minesweeper game. I’ve been given a template and am working off of that. Right now my problem is two things: I need to write a function (I have it called drawMines), where it will acce…

---

## [Creating 2D Obstacle-Dodging Game](https://discourse.processing.org/t/creating-2d-obstacle-dodging-game/16196)

<div class="topic-metadata">

**Author:** [@beanbagchair](https://discourse.processing.org/u/beanbagchair)\
**Replies:** 1\
**Last updated:** [December 7, 2019, 2:34am UTC](https://discourse.processing.org/t/creating-2d-obstacle-dodging-game/16196 "2019-12-07T02:34:02Z")

</div>

Hi, I am taking an Object-Oriented Programming class, and our final project can be anything we want. I decided to create a game which has a car traveling around a track, with a random set of objects appearing on the tra…

---

## [Multiple Instances only drawing last instance](https://discourse.processing.org/t/multiple-instances-only-drawing-last-instance/16186)

<div class="topic-metadata">

**Author:** [@Andrew](https://discourse.processing.org/u/Andrew)\
**Replies:** 2\
**Last updated:** [December 6, 2019, 7:40pm UTC](https://discourse.processing.org/t/multiple-instances-only-drawing-last-instance/16186 "2019-12-06T19:40:57Z")

</div>

I’m just getting started with Processing (3.5.3), and so far it’s been pretty fun. However, I’ve hit a snag, and even after researching for a couple hours I still can’t figure it out. I try to create two instances of ci…

---

## [Finding wordcount/frequency with a given text file](https://discourse.processing.org/t/finding-wordcount-frequency-with-a-given-text-file/16178)

<div class="topic-metadata">

**Author:** [@bc15](https://discourse.processing.org/u/bc15)\
**Replies:** 3\
**Last updated:** [December 6, 2019, 7:27pm UTC](https://discourse.processing.org/t/finding-wordcount-frequency-with-a-given-text-file/16178 "2019-12-06T19:27:46Z")

</div>

I have a decent idea on how to visualize it with a box plot as it was practiced during class, but I’m having trouble calculating the frequency of each words by modifying the given code :frowning: Read in the text file. …

---

## [Finding unique/distinct values in a list](https://discourse.processing.org/t/finding-unique-distinct-values-in-a-list/16183)

<div class="topic-metadata">

**Author:** [@Lehmoxy](https://discourse.processing.org/u/Lehmoxy)\
**Replies:** 3\
**Last updated:** [December 6, 2019, 6:43pm UTC](https://discourse.processing.org/t/finding-unique-distinct-values-in-a-list/16183 "2019-12-06T18:43:34Z")

</div>

Hello all, I’m wondering if there is a function in processing to find unique/distinct values in arrays/lists. I am trying to make a dropdown menu from an imported data set. For example, if I have an array of 5 elements …

---

## [Letra desenfocada](https://discourse.processing.org/t/letra-desenfocada/16169)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 2\
**Last updated:** [December 6, 2019, 2:45pm UTC](https://discourse.processing.org/t/letra-desenfocada/16169 "2019-12-06T14:45:02Z")

</div>

Hi guys, This text does not look very clear, can somebody tell me how make it more defined? Thanks void setup(){ size(270,540); background(0,0,0); noStroke(); smooth(); } void draw() { fill(255, 255, 255,…

---

## [Degradado en fondo con temblor (Gradient in background with tremor)](https://discourse.processing.org/t/degradado-en-fondo-con-temblor-gradient-in-background-with-tremor/16134)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 15\
**Last updated:** [December 6, 2019, 10:37am UTC](https://discourse.processing.org/t/degradado-en-fondo-con-temblor-gradient-in-background-with-tremor/16134 "2019-12-06T10:37:27Z")

</div>

Hi guys, I have a problem with the background of my program. If it is a solid color, everything works, buti if I draw a gradient, animation trembles. Can you recomend me any solution? Thank you very much. int x; int se…

---

## [Problem with boolean changing to false randomly](https://discourse.processing.org/t/problem-with-boolean-changing-to-false-randomly/16152)

<div class="topic-metadata">

**Author:** [@TurboSlayer](https://discourse.processing.org/u/TurboSlayer)\
**Replies:** 3\
**Last updated:** [December 6, 2019, 8:59am UTC](https://discourse.processing.org/t/problem-with-boolean-changing-to-false-randomly/16152 "2019-12-06T08:59:47Z")

</div>

So I’ve made another code using if else instead of a switch, but more problems arise. For some stupid reason, whenever I press “1” on my keyboard, it sets game to false? As you can see in the code below, I didn’t make i…

---

## [Array interaction problem!](https://discourse.processing.org/t/array-interaction-problem/16117)

<div class="topic-metadata">

**Author:** [@tsunii](https://discourse.processing.org/u/tsunii)\
**Replies:** 14\
**Last updated:** [December 5, 2019, 10:35pm UTC](https://discourse.processing.org/t/array-interaction-problem/16117 "2019-12-05T22:35:55Z")

</div>

My question are: Why i’m getting 4 valour for every p\[i\], i should have 4 circle but i have 16! Why the “fase 1” ir rolling forever Why c\[i\] isnt getting any value for now that’s it! //Quantidade de circulo\] int ct =…

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

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