# Coding Questions

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

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

**Page:** 67

---

## [Problem coding Java (TRIANGLE\_FAN )](https://discourse.processing.org/t/problem-coding-java-triangle-fan/26935)

<div class="topic-metadata">

**Author:** [@hom1](https://discourse.processing.org/u/hom1)\
**Replies:** 1\
**Last updated:** [January 10, 2021, 1:10am UTC](https://discourse.processing.org/t/problem-coding-java-triangle-fan/26935 "2021-01-10T01:10:03Z")

</div>

please format code with \</\> button \* homework policy \* asking questions How to create TRIANGLE\_FAN?

---

## [Drawing a shader generated PGraphics onto a non OpenGL PGraphics object](https://discourse.processing.org/t/drawing-a-shader-generated-pgraphics-onto-a-non-opengl-pgraphics-object/26264)

<div class="topic-metadata">

**Author:** [@r.jaoui](https://discourse.processing.org/u/r.jaoui)\
**Replies:** 6\
**Last updated:** [January 9, 2021, 8:37pm UTC](https://discourse.processing.org/t/drawing-a-shader-generated-pgraphics-onto-a-non-opengl-pgraphics-object/26264 "2021-01-09T20:37:46Z")

</div>

Hello everyone ! I am currently developping quite a big project, and for simplicity I have chosen to use Processing as a graphical engine. I am coding with Eclipse Neon. The issue is that I have developped GLSL Fragmen…

---

## [Dijkstra Algorithm view (Node, Edges)](https://discourse.processing.org/t/dijkstra-algorithm-view-node-edges/26891)

<div class="topic-metadata">

**Author:** [@librakl](https://discourse.processing.org/u/librakl)\
**Replies:** 20\
**Last updated:** [January 9, 2021, 3:39pm UTC](https://discourse.processing.org/t/dijkstra-algorithm-view-node-edges/26891 "2021-01-09T15:39:04Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hello, we have to implement the Dijkstra Algorithm. But at the beginning you have an empty field where you can click to create the nodes and ed…

---

## [LerpColor on Arc?](https://discourse.processing.org/t/lerpcolor-on-arc/26880)

<div class="topic-metadata">

**Author:** [@toninhorodrigues](https://discourse.processing.org/u/toninhorodrigues)\
**Replies:** 5\
**Last updated:** [January 9, 2021, 12:34pm UTC](https://discourse.processing.org/t/lerpcolor-on-arc/26880 "2021-01-09T12:34:15Z")

</div>

Hi there, I’m fairly new to Processing, and have been trying to make a single arc with a gradient style. I tried searching around, but have only found gradient codes for straight line objects, such as rectangle, the fu…

---

## [Getting shaked when using textAlign(CENTER, CENTER)](https://discourse.processing.org/t/getting-shaked-when-using-textalign-center-center/26835)

<div class="topic-metadata">

**Author:** [@yhlaskerimov](https://discourse.processing.org/u/yhlaskerimov)\
**Replies:** 6\
**Last updated:** [January 9, 2021, 7:13am UTC](https://discourse.processing.org/t/getting-shaked-when-using-textalign-center-center/26835 "2021-01-09T07:13:38Z")

</div>

Hi, everyone ! When I use sin() funtion to shrink my text’s size I am getting a shaky effect with textAlign(CENTER, CENTER). I have to use it with textAlign(CENTER, CENTER) but without shaky effect. Here is my code whi…

---

## [Comparing two ArrayList of Objects to find differences](https://discourse.processing.org/t/comparing-two-arraylist-of-objects-to-find-differences/26860)

<div class="topic-metadata">

**Author:** [@fedpep](https://discourse.processing.org/u/fedpep)\
**Replies:** 6\
**Last updated:** [January 8, 2021, 2:14pm UTC](https://discourse.processing.org/t/comparing-two-arraylist-of-objects-to-find-differences/26860 "2021-01-08T14:14:44Z")

</div>

Hello! I am working with two ArrayList of objects with more than 6000 elements for each ArrayList. Most of these objects are the same but I need to find what are the differences between the two lists. Is there a quick w…

---

## [How do you detect / stop someone from closing the sketch?](https://discourse.processing.org/t/how-do-you-detect-stop-someone-from-closing-the-sketch/26864)

<div class="topic-metadata">

**Author:** [@what42](https://discourse.processing.org/u/what42)\
**Replies:** 2\
**Last updated:** [January 7, 2021, 10:11pm UTC](https://discourse.processing.org/t/how-do-you-detect-stop-someone-from-closing-the-sketch/26864 "2021-01-07T22:11:35Z")

</div>

I want to have some code run before the sketch is closed, but I don’t know how to detect when the window itself has been closed by clicking its x. I’d also be okay with making the window borderless, but I can’t find a wa…

---

## [Slow Movement of player to mouse position on mouse click](https://discourse.processing.org/t/slow-movement-of-player-to-mouse-position-on-mouse-click/26844)

<div class="topic-metadata">

**Author:** [@Leonniclass](https://discourse.processing.org/u/Leonniclass)\
**Replies:** 2\
**Last updated:** [January 6, 2021, 9:22pm UTC](https://discourse.processing.org/t/slow-movement-of-player-to-mouse-position-on-mouse-click/26844 "2021-01-06T21:22:54Z")

</div>

Hello, I am new to processing and I have to make a game were the user clicks somewhere in the window and the ball will move to the position. It is pretty simple, but I cant figure it out :sweat\_smile: I havent found som…

---

## [How do i detect when spacebar is pressed?](https://discourse.processing.org/t/how-do-i-detect-when-spacebar-is-pressed/26845)

<div class="topic-metadata">

**Author:** [@nanto2016](https://discourse.processing.org/u/nanto2016)\
**Replies:** 2\
**Last updated:** [January 6, 2021, 8:47pm UTC](https://discourse.processing.org/t/how-do-i-detect-when-spacebar-is-pressed/26845 "2021-01-06T20:47:17Z")

</div>

well I want my character to jump when i press spacebar, but it doesn’t work. void keyPressed(){ //i'd like to detect when space bar is pressed. if(key==' '){} //it did'nt work though :( } i saw (key==’ ') in other c…

---

## [Simple sketch issue (mouse over sets color)](https://discourse.processing.org/t/simple-sketch-issue-mouse-over-sets-color/26806)

<div class="topic-metadata">

**Author:** [@DamoBailey](https://discourse.processing.org/u/DamoBailey)\
**Replies:** 13\
**Last updated:** [January 6, 2021, 7:28am UTC](https://discourse.processing.org/t/simple-sketch-issue-mouse-over-sets-color/26806 "2021-01-06T07:28:32Z")

</div>

Hi I am a complete beginner and am working on the following project: Create a 500x500 grey area split into 4 equal quadrants. Show one quadrant as blue when the mouse is in that quadrant (all other quadrants shown as g…

---

## [Galaga projectile motion](https://discourse.processing.org/t/galaga-projectile-motion/26757)

<div class="topic-metadata">

**Author:** [@lionR](https://discourse.processing.org/u/lionR)\
**Replies:** 12\
**Last updated:** [January 5, 2021, 9:40pm UTC](https://discourse.processing.org/t/galaga-projectile-motion/26757 "2021-01-05T21:40:27Z")

</div>

//Global Variables PImage player, enemy, rocket; int playerX; int rocketX; int rocketY; //Following variables from funprogramming.org float\[\] x = new float\[250\];// creates x values for 250 stars float\[\] y = new float…

---

## [PLEASE DELETE THIS POST: Problems with constructor of Class](https://discourse.processing.org/t/please-delete-this-post-problems-with-constructor-of-class/26796)

<div class="topic-metadata">

**Author:** [@Beto](https://discourse.processing.org/u/Beto)\
**Replies:** 4\
**Last updated:** [January 5, 2021, 5:05pm UTC](https://discourse.processing.org/t/please-delete-this-post-problems-with-constructor-of-class/26796 "2021-01-05T17:05:21Z")

</div>

My code will be uploaded later in a new topic. If an admin comes across this topic, please delete.

---

## [Array of Images Error (loading of images)](https://discourse.processing.org/t/array-of-images-error-loading-of-images/26725)

<div class="topic-metadata">

**Author:** [@ELaN](https://discourse.processing.org/u/ELaN)\
**Replies:** 23\
**Last updated:** [January 4, 2021, 4:28pm UTC](https://discourse.processing.org/t/array-of-images-error-loading-of-images/26725 "2021-01-04T16:28:36Z")

</div>

Whenever I write this code: PImage\[\] flowers=new PImage\[3\]; Bubble\[\] bubbles=new Bubble\[5\]; void setup() { size(640, 360); for(int i=0; i\<flowers.length; i++){ flowers\[i\]=loadImage(“flower”+i+".jpg"); } for(int i…

---

## [I need your help please (image on/off)](https://discourse.processing.org/t/i-need-your-help-please-image-on-off/26755)

<div class="topic-metadata">

**Author:** [@PIlw](https://discourse.processing.org/u/PIlw)\
**Replies:** 3\
**Last updated:** [January 4, 2021, 12:40pm UTC](https://discourse.processing.org/t/i-need-your-help-please-image-on-off/26755 "2021-01-04T12:40:21Z")

</div>

Hello guys, I need help please, The thing would be, when I press a key an image appears and when I press it again it disappears. i’ve made it into my code and the image doesn’t shows up I put my code here and if someo…

---

## [How convert the Traveling Salesperson JS to Object-oriented Programming style Java Processing](https://discourse.processing.org/t/how-convert-the-traveling-salesperson-js-to-object-oriented-programming-style-java-processing/26691)

<div class="topic-metadata">

**Author:** [@psamead](https://discourse.processing.org/u/psamead)\
**Replies:** 9\
**Last updated:** [January 4, 2021, 11:47am UTC](https://discourse.processing.org/t/how-convert-the-traveling-salesperson-js-to-object-oriented-programming-style-java-processing/26691 "2021-01-04T11:47:56Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Dear friends, I am learning the Processing and trying to convert Daniel’s ‘Traveling Sales Person’ JavaScript to the Java Processing in the Obj…

---

## [I need your help please (image on / off)](https://discourse.processing.org/t/i-need-your-help-please-image-on-off/26741)

<div class="topic-metadata">

**Author:** [@PIlw](https://discourse.processing.org/u/PIlw)\
**Replies:** 3\
**Last updated:** [January 4, 2021, 11:41am UTC](https://discourse.processing.org/t/i-need-your-help-please-image-on-off/26741 "2021-01-04T11:41:05Z")

</div>

Hello guys, I would like to do something but I don’t know how : The thing would be, when I press a key an image appears and when I press it again it disappears. I know that it must be something whit keyPressed, but i …

---

## [Dynamic PVector arraylist drawing a smooth line](https://discourse.processing.org/t/dynamic-pvector-arraylist-drawing-a-smooth-line/26762)

<div class="topic-metadata">

**Author:** [@dimpapadop](https://discourse.processing.org/u/dimpapadop)\
**Replies:** 5\
**Last updated:** [January 4, 2021, 9:56am UTC](https://discourse.processing.org/t/dynamic-pvector-arraylist-drawing-a-smooth-line/26762 "2021-01-04T09:56:01Z")

</div>

Hallo. I have a sketch with 2 applets, the first is creating an Arraylist of Pvectors points for example when mouse Dragged adds points.add(new PVector(mouseX, mouseY));, and the second draws the line that passes the p…

---

## [Can someone create two loops out of this code?](https://discourse.processing.org/t/can-someone-create-two-loops-out-of-this-code/26760)

<div class="topic-metadata">

**Author:** [@popin](https://discourse.processing.org/u/popin)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 6:50am UTC](https://discourse.processing.org/t/can-someone-create-two-loops-out-of-this-code/26760 "2021-01-04T06:50:06Z")

</div>

Hey guys, is it possible to create two loops out of this code? thank you! color\[\] colors = { #654321, #A0522D, #000000, #8B4513, #64190D, #00FF00 }; int circleX, circleY; int circle1X, circle1Y; int circle2X,…

---

## [My sketch is smooth until i zoom in (drop to 15fps)](https://discourse.processing.org/t/my-sketch-is-smooth-until-i-zoom-in-drop-to-15fps/26714)

<div class="topic-metadata">

**Author:** [@WillG](https://discourse.processing.org/u/WillG)\
**Replies:** 3\
**Last updated:** [January 3, 2021, 11:38pm UTC](https://discourse.processing.org/t/my-sketch-is-smooth-until-i-zoom-in-drop-to-15fps/26714 "2021-01-03T23:38:03Z")

</div>

Hello there, for a school project, i’ve created a map with bus point and density at these bus point. Everything works fine except the frame rate when i zoom in with the slider. But i can’t remove it cause the teacher wa…

---

## [Draw code frame by frame](https://discourse.processing.org/t/draw-code-frame-by-frame/26687)

<div class="topic-metadata">

**Author:** [@Sophie](https://discourse.processing.org/u/Sophie)\
**Replies:** 7\
**Last updated:** [January 3, 2021, 6:39pm UTC](https://discourse.processing.org/t/draw-code-frame-by-frame/26687 "2021-01-03T18:39:12Z")

</div>

Hello, I am new to Processing and need help with a problem. I need the code in draw not to be played completely over and over again, but frame by frame. The background should change his color according to the first char…

---

## [Geologic cross section with a rule](https://discourse.processing.org/t/geologic-cross-section-with-a-rule/26679)

<div class="topic-metadata">

**Author:** [@Huno](https://discourse.processing.org/u/Huno)\
**Replies:** 1\
**Last updated:** [January 2, 2021, 11:24pm UTC](https://discourse.processing.org/t/geologic-cross-section-with-a-rule/26679 "2021-01-02T23:24:48Z")

</div>

Hello! I’ve trying to make a geologic cross section for a while but I have not even had any idea on how to start. My goal is to do this 2d random graphic based on a simple rule. the idea is to: Draw a line Divide tha…

---

## [Help with mousePressed or keyPressed](https://discourse.processing.org/t/help-with-mousepressed-or-keypressed/26689)

<div class="topic-metadata">

**Author:** [@PIlw](https://discourse.processing.org/u/PIlw)\
**Replies:** 3\
**Last updated:** [January 2, 2021, 4:43pm UTC](https://discourse.processing.org/t/help-with-mousepressed-or-keypressed/26689 "2021-01-02T16:43:34Z")

</div>

Hello guys, I need help to make this code into mouse pressed or keypressed so I want that the code appears only if I press the mouse or a key as you want but if someone could help me it would be amazing ! class bug { …

---

## [Combine 2 codes](https://discourse.processing.org/t/combine-2-codes/26671)

<div class="topic-metadata">

**Author:** [@PIlw](https://discourse.processing.org/u/PIlw)\
**Replies:** 4\
**Last updated:** [January 2, 2021, 3:34pm UTC](https://discourse.processing.org/t/combine-2-codes/26671 "2021-01-02T15:34:35Z")

</div>

Hello guys, I’ve a question : The thing is that I have 2 codes and I want to combine them like this ; the basic code would be the image of DVD mooving across the screen and then put a mousePressed line so when we press …

---

## [How to access variables from PApplet (2nd window) in default window?](https://discourse.processing.org/t/how-to-access-variables-from-papplet-2nd-window-in-default-window/26670)

<div class="topic-metadata">

**Author:** [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Replies:** 2\
**Last updated:** [January 2, 2021, 10:44am UTC](https://discourse.processing.org/t/how-to-access-variables-from-papplet-2nd-window-in-default-window/26670 "2021-01-02T10:44:21Z")

</div>

Hi! I recently saw someone’s code which allowed for 2 windows. I tried to adapt one of my programs to it but it didn’t work too well. I know I can just declare them at the beginning and be done with it, but is there a w…

---

## [Finding vector pointing "down" on 2d plane](https://discourse.processing.org/t/finding-vector-pointing-down-on-2d-plane/26567)

<div class="topic-metadata">

**Author:** [@arcadeperfect](https://discourse.processing.org/u/arcadeperfect)\
**Replies:** 2\
**Last updated:** [January 2, 2021, 3:23am UTC](https://discourse.processing.org/t/finding-vector-pointing-down-on-2d-plane/26567 "2021-01-02T03:23:26Z")

</div>

I guess this is more math than Processing per se but here goes… The 2D plane exists in 3D space and can rotate in any direction about the origin (from gyro data). How can I find the vector shown in blue that always poi…

---

## [2 for loops inside a String function](https://discourse.processing.org/t/2-for-loops-inside-a-string-function/26669)

<div class="topic-metadata">

**Author:** [@JoLi](https://discourse.processing.org/u/JoLi)\
**Replies:** 4\
**Last updated:** [January 1, 2021, 4:54pm UTC](https://discourse.processing.org/t/2-for-loops-inside-a-string-function/26669 "2021-01-01T16:54:57Z")

</div>

why is this not working? yea, I know I dont need that boolean finished in the beginning

---

## [How to give circles(ellipses) certain distance, apart from each other? giving random position every time I press key](https://discourse.processing.org/t/how-to-give-circles-ellipses-certain-distance-apart-from-each-other-giving-random-position-every-time-i-press-key/26646)

<div class="topic-metadata">

**Author:** [@yewon](https://discourse.processing.org/u/yewon)\
**Replies:** 10\
**Last updated:** [January 1, 2021, 2:01pm UTC](https://discourse.processing.org/t/how-to-give-circles-ellipses-certain-distance-apart-from-each-other-giving-random-position-every-time-i-press-key/26646 "2021-01-01T14:01:53Z")

</div>

Hi. what I want to do is, Every time I press key, I want to reposition my object inside screen, but each of my object should be apart from each other by certain distance. for example at least the distance should be lar…

---

## [Why multiple windows can't show sketch correctly?](https://discourse.processing.org/t/why-multiple-windows-cant-show-sketch-correctly/26659)

<div class="topic-metadata">

**Author:** [@IpNeNaEcRe](https://discourse.processing.org/u/IpNeNaEcRe)\
**Replies:** 2\
**Last updated:** [January 1, 2021, 7:43am UTC](https://discourse.processing.org/t/why-multiple-windows-cant-show-sketch-correctly/26659 "2021-01-01T07:43:21Z")

</div>

I want to create multiple windows, one to interact (put slide bar in it) and other to show the sketch. Now I can draw line/rectangle/ellipse directly in the second window. When these things in another class and use the c…

---

## [Interacting with images](https://discourse.processing.org/t/interacting-with-images/26648)

<div class="topic-metadata">

**Author:** [@PIlw](https://discourse.processing.org/u/PIlw)\
**Replies:** 2\
**Last updated:** [December 31, 2020, 11:09pm UTC](https://discourse.processing.org/t/interacting-with-images/26648 "2020-12-31T23:09:32Z")

</div>

Hello guys, I am a beginner on processing and i would like to do something : The thing would be to have 2 images mooving across the screen and when they touch eachother they hit and change directions. for the moment I’…

---

## [Need a review to improve this :)](https://discourse.processing.org/t/need-a-review-to-improve-this/26630)

<div class="topic-metadata">

**Author:** [@jeanphih](https://discourse.processing.org/u/jeanphih)\
**Replies:** 7\
**Last updated:** [December 31, 2020, 6:50pm UTC](https://discourse.processing.org/t/need-a-review-to-improve-this/26630 "2020-12-31T18:50:09Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hello, I need some help, i have done this job , could you tell me how i can make my code better ? Here is the code, it s juste some tips to im…

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

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