# Coding Questions

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

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

**Page:** 83

---

## [Detection of collision between elements from same array only works sometimes](https://discourse.processing.org/t/detection-of-collision-between-elements-from-same-array-only-works-sometimes/23447)

<div class="topic-metadata">

**Author:** [@Leonsuper](https://discourse.processing.org/u/Leonsuper)\
**Replies:** 6\
**Last updated:** [August 24, 2020, 11:16am UTC](https://discourse.processing.org/t/detection-of-collision-between-elements-from-same-array-only-works-sometimes/23447 "2020-08-24T11:16:07Z")

</div>

Hello! I’ve created a small program where circles stored in an array move through the window. They rebound when they hit the window’s limits and they’re supposed to rebound when they collide with each other, but thesse …

---

## [Make one of my sketches a screensaver](https://discourse.processing.org/t/make-one-of-my-sketches-a-screensaver/23456)

<div class="topic-metadata">

**Author:** [@Crysp](https://discourse.processing.org/u/Crysp)\
**Replies:** 1\
**Last updated:** [August 24, 2020, 9:34am UTC](https://discourse.processing.org/t/make-one-of-my-sketches-a-screensaver/23456 "2020-08-24T09:34:58Z")

</div>

Hello, I want to make one of my Processing sketches my screensaver, and am wondering if there was a way that I can make it one. Here is the sketch that I am talking about if you’re interested. I have Windows 10 if that i…

---

## [textWidth() .... what is being returned?](https://discourse.processing.org/t/textwidth-what-is-being-returned/7864)

<div class="topic-metadata">

**Author:** [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Replies:** 8\
**Last updated:** [August 24, 2020, 5:30am UTC](https://discourse.processing.org/t/textwidth-what-is-being-returned/7864 "2020-08-24T05:30:43Z")

</div>

Just playing with text and think that textWidth() returns a length that includes an added space? Test code: String\[\] strArray = {"the", "quick", "brown", "fox"} ; int xOffset = 0 ; void setup() { size(400, 400) ; …

---

## [Problem with storing user-entered text in a string](https://discourse.processing.org/t/problem-with-storing-user-entered-text-in-a-string/23348)

<div class="topic-metadata">

**Author:** [@benvining](https://discourse.processing.org/u/benvining)\
**Replies:** 9\
**Last updated:** [August 23, 2020, 2:58pm UTC](https://discourse.processing.org/t/problem-with-storing-user-entered-text-in-a-string/23348 "2020-08-23T14:58:59Z")

</div>

Hello all! As part of a larger project, I created a popup window where a user can enter some text (to change their username in a game). I have a String that stores the player’s username and a separate String that stores …

---

## [Too many calls to pushMatrix()](https://discourse.processing.org/t/too-many-calls-to-pushmatrix/23411)

<div class="topic-metadata">

**Author:** [@todai](https://discourse.processing.org/u/todai)\
**Replies:** 8\
**Last updated:** [August 23, 2020, 2:31am UTC](https://discourse.processing.org/t/too-many-calls-to-pushmatrix/23411 "2020-08-23T02:31:02Z")

</div>

Hey, Is there a way to increase the matrix stack depth for pushMatrix()? I am working with 3D objects that have to be displayed with a relative position from one and other. The 3D objects are all created with box() fro…

---

## [How do I make the snake's tail add on when i hit the apple?](https://discourse.processing.org/t/how-do-i-make-the-snakes-tail-add-on-when-i-hit-the-apple/23322)

<div class="topic-metadata">

**Author:** [@cdixo82](https://discourse.processing.org/u/cdixo82)\
**Replies:** 3\
**Last updated:** [August 20, 2020, 9:14pm UTC](https://discourse.processing.org/t/how-do-i-make-the-snakes-tail-add-on-when-i-hit-the-apple/23322 "2020-08-20T21:14:47Z")

</div>

ArrayList\<Integer\> x = new ArrayList\<Integer\>(); ArrayList\<Integer\> y = new ArrayList\<Integer\>(); int gridSize = 20; int h = height; int w = height; int xdir = 0; int ydir = 0; boolean eaten = false; int applex; int app…

---

## [Slow performance when passing multiple PGraphics into each other as shader textures](https://discourse.processing.org/t/slow-performance-when-passing-multiple-pgraphics-into-each-other-as-shader-textures/23384)

<div class="topic-metadata">

**Author:** [@neel](https://discourse.processing.org/u/neel)\
**Replies:** 2\
**Last updated:** [August 20, 2020, 1:10pm UTC](https://discourse.processing.org/t/slow-performance-when-passing-multiple-pgraphics-into-each-other-as-shader-textures/23384 "2020-08-20T13:10:48Z")

</div>

Hey all, I’m attempting to use multiple pgraphics objects for my code. I want to draw some shapes on the first pgraphics. I then want to use a shader on the second pgraphics object to apply blur to the red channel and t…

---

## [Any way to write to just the R, G, or B channel of the canvas? blendMode(ADD) is not working as expected](https://discourse.processing.org/t/any-way-to-write-to-just-the-r-g-or-b-channel-of-the-canvas-blendmode-add-is-not-working-as-expected/23347)

<div class="topic-metadata">

**Author:** [@neel](https://discourse.processing.org/u/neel)\
**Replies:** 7\
**Last updated:** [August 20, 2020, 1:09pm UTC](https://discourse.processing.org/t/any-way-to-write-to-just-the-r-g-or-b-channel-of-the-canvas-blendmode-add-is-not-working-as-expected/23347 "2020-08-20T13:09:30Z")

</div>

Hey all. I’m trying to use blendMode() in a pretty specific way, but I’m getting results I wouldn’t expect. I would like to draw random red rectangles (255,0,0) and green rectangles (0,255,0) and then use a fragment shad…

---

## [Is it possible to fill pixel information with an array of images?](https://discourse.processing.org/t/is-it-possible-to-fill-pixel-information-with-an-array-of-images/23325)

<div class="topic-metadata">

**Author:** [@jesspayne](https://discourse.processing.org/u/jesspayne)\
**Replies:** 2\
**Last updated:** [August 19, 2020, 5:22pm UTC](https://discourse.processing.org/t/is-it-possible-to-fill-pixel-information-with-an-array-of-images/23325 "2020-08-19T17:22:57Z")

</div>

Hi all, I’m working on a uni project and wondered whether Processing could help. I’m looking to fill the pixels of an image with an array of photographs. I have come across this tutorial but not sure how to substitute t…

---

## [Key repeat function](https://discourse.processing.org/t/key-repeat-function/23358)

<div class="topic-metadata">

**Author:** [@rasheeda](https://discourse.processing.org/u/rasheeda)\
**Replies:** 3\
**Last updated:** [August 19, 2020, 4:43pm UTC](https://discourse.processing.org/t/key-repeat-function/23358 "2020-08-19T16:43:17Z")

</div>

I have implemented ball bouncing by boundary. Keypressed function accept arrow key. How to process keyrepeat when key is kept pressed. Keypressed is generated only when key is released and pressed again. Appreciate an…

---

## [How to mouseclicked()](https://discourse.processing.org/t/how-to-mouseclicked/23316)

<div class="topic-metadata">

**Author:** [@greenknight71](https://discourse.processing.org/u/greenknight71)\
**Replies:** 2\
**Last updated:** [August 19, 2020, 3:36am UTC](https://discourse.processing.org/t/how-to-mouseclicked/23316 "2020-08-19T03:36:50Z")

</div>

How does mouseClicked() work? Im trying to make it so that when a mouse is clicked, it ends. void mouseClicked(){ if(shot){ end(); } else{ return; } }

---

## [Help with launch()](https://discourse.processing.org/t/help-with-launch/23323)

<div class="topic-metadata">

**Author:** [@CaseyJ](https://discourse.processing.org/u/CaseyJ)\
**Replies:** 7\
**Last updated:** [August 18, 2020, 4:44pm UTC](https://discourse.processing.org/t/help-with-launch/23323 "2020-08-18T16:44:19Z")

</div>

Looking into how to trigger a task, script, or executable in Processing. Basically I want Processing to run a script that deletes all files if there are any files in a folder during startup. I found this script works g…

---

## [How to render an overlay window within a Processing sketch?](https://discourse.processing.org/t/how-to-render-an-overlay-window-within-a-processing-sketch/23326)

<div class="topic-metadata">

**Author:** [@benvining](https://discourse.processing.org/u/benvining)\
**Replies:** 5\
**Last updated:** [August 18, 2020, 2:11pm UTC](https://discourse.processing.org/t/how-to-render-an-overlay-window-within-a-processing-sketch/23326 "2020-08-18T14:11:59Z")

</div>

Hello everyone, I’m working on creating a (relatively) simple Pokemon-like game in Processing – but it is complex enough that there are several different screens the user can be viewing. For example, there’s a user prof…

---

## [Target VM failed to initialize on Mac](https://discourse.processing.org/t/target-vm-failed-to-initialize-on-mac/23329)

<div class="topic-metadata">

**Author:** [@benvining](https://discourse.processing.org/u/benvining)\
**Replies:** 1\
**Last updated:** [August 18, 2020, 11:41am UTC](https://discourse.processing.org/t/target-vm-failed-to-initialize-on-mac/23329 "2020-08-18T11:41:05Z")

</div>

Hello all, I know there have been discussions about this issue in the past, but most of the solutions I can find online are dealing with Windows computers with Nvidia graphics cards. I am on a MacBook Pro, running OSX 1…

---

## [Table .sort() function not working?](https://discourse.processing.org/t/table-sort-function-not-working/23283)

<div class="topic-metadata">

**Author:** [@benvining](https://discourse.processing.org/u/benvining)\
**Replies:** 3\
**Last updated:** [August 18, 2020, 7:43am UTC](https://discourse.processing.org/t/table-sort-function-not-working/23283 "2020-08-18T07:43:15Z")

</div>

Hi everyone, I have a Table that I’ve loaded from an external .csv file, and I’d like to sort the table rows by numeric values in a certain column. However, when I run Table.sort() or Table.sortReverse(), it keeps givi…

---

## [Seven Nation Army effect](https://discourse.processing.org/t/seven-nation-army-effect/23293)

<div class="topic-metadata">

**Author:** [@senior-byte](https://discourse.processing.org/u/senior-byte)\
**Replies:** 0\
**Last updated:** [August 16, 2020, 3:22pm UTC](https://discourse.processing.org/t/seven-nation-army-effect/23293 "2020-08-16T15:22:43Z")

</div>

Hey guys, I need some help. I try to create a real live version of the „Seven Nation Army - The White Stripes“ music clip with a webcam. So, the small video in the front which is getting bigger should have a transparen…

---

## [Get the vertical axis of object's array](https://discourse.processing.org/t/get-the-vertical-axis-of-objects-array/23319)

<div class="topic-metadata">

**Author:** [@chanof](https://discourse.processing.org/u/chanof)\
**Replies:** 4\
**Last updated:** [August 18, 2020, 3:40am UTC](https://discourse.processing.org/t/get-the-vertical-axis-of-objects-array/23319 "2020-08-18T03:40:05Z")

</div>

Im trying to center this cluster of cubes, to be able to rotate them on the vertical axis, currently it rotate by using the corner as axis, i tried a lot instruments, translate, ortho, rotate, i really need a hand to fi…

---

## [Gravity in a solar system](https://discourse.processing.org/t/gravity-in-a-solar-system/23299)

<div class="topic-metadata">

**Author:** [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Replies:** 5\
**Last updated:** [August 17, 2020, 2:36pm UTC](https://discourse.processing.org/t/gravity-in-a-solar-system/23299 "2020-08-17T14:36:11Z")

</div>

I’m trying to simulate a solar system type thing where on planet orbits around a sun. The planet has an initial velocity of x+2. However, it always seems to follow this long elliptical orbit. I’m trying to get it so tha…

---

## [PDF export with createGraphics won't play nice with selectOutput file selector](https://discourse.processing.org/t/pdf-export-with-creategraphics-wont-play-nice-with-selectoutput-file-selector/23289)

<div class="topic-metadata">

**Author:** [@raron](https://discourse.processing.org/u/raron)\
**Replies:** 1\
**Last updated:** [August 17, 2020, 4:37pm UTC](https://discourse.processing.org/t/pdf-export-with-creategraphics-wont-play-nice-with-selectoutput-file-selector/23289 "2020-08-17T16:37:22Z")

</div>

I might be a bit over my head, apologies for the semi-long sketch and wall-of-text. I’m really puzzled by this! I have a sketch with a PDF export that works great on it’s own, but that just saves a file in the sketch fo…

---

## [Whack-A-Mole Game](https://discourse.processing.org/t/whack-a-mole-game/23113)

<div class="topic-metadata">

**Author:** [@chemicalite](https://discourse.processing.org/u/chemicalite)\
**Replies:** 9\
**Last updated:** [August 17, 2020, 2:30pm UTC](https://discourse.processing.org/t/whack-a-mole-game/23113 "2020-08-17T14:30:14Z")

</div>

Hello there! I am a somewhat beginner in Processing. So far, all I’ve learned is for and while loops, simple animation, if and if else statements, drawing primitives, and some other related things along with relative ba…

---

## [Text() overlaps itself every time draw() is called no matter what](https://discourse.processing.org/t/text-overlaps-itself-every-time-draw-is-called-no-matter-what/23298)

<div class="topic-metadata">

**Author:** [@Crysp](https://discourse.processing.org/u/Crysp)\
**Replies:** 3\
**Last updated:** [August 17, 2020, 1:59am UTC](https://discourse.processing.org/t/text-overlaps-itself-every-time-draw-is-called-no-matter-what/23298 "2020-08-17T01:59:44Z")

</div>

I am trying to make Conway’s Game Of Life in Processing and everything works, but I want to have a textbox that shows how many generations have passed. I opted to use the text() command, which looks as follows: fill(255…

---

## [Rotate a smilie around its center](https://discourse.processing.org/t/rotate-a-smilie-around-its-center/23291)

<div class="topic-metadata">

**Author:** [@txwgnd](https://discourse.processing.org/u/txwgnd)\
**Replies:** 2\
**Last updated:** [August 16, 2020, 7:36pm UTC](https://discourse.processing.org/t/rotate-a-smilie-around-its-center/23291 "2020-08-16T19:36:45Z")

</div>

Hello, i try to write a method that rotates my Smilie object around its center axis. The show() function draws the complete object based on the center coordinates. The problem is that when I try to rotate the whole th…

---

## [Looping logical operators?](https://discourse.processing.org/t/looping-logical-operators/23267)

<div class="topic-metadata">

**Author:** [@eltrem](https://discourse.processing.org/u/eltrem)\
**Replies:** 2\
**Last updated:** [August 15, 2020, 4:51pm UTC](https://discourse.processing.org/t/looping-logical-operators/23267 "2020-08-15T16:51:06Z")

</div>

Hi all! I’m wondering if there’s a way to evaluate operators in a loop… ooops…i hope this statement makes any sense… maybe it is better if i show my code first: for(int i=0; i\<height; i++){ if((scalenotes.hasVal…

---

## [No shading after flipping x axis wth scale(-1, 1, 1). How to fix this?](https://discourse.processing.org/t/no-shading-after-flipping-x-axis-wth-scale-1-1-1-how-to-fix-this/23177)

<div class="topic-metadata">

**Author:** [@brcow](https://discourse.processing.org/u/brcow)\
**Replies:** 8\
**Last updated:** [August 15, 2020, 2:33pm UTC](https://discourse.processing.org/t/no-shading-after-flipping-x-axis-wth-scale-1-1-1-how-to-fix-this/23177 "2020-08-15T14:33:14Z")

</div>

The following simple code works perfectly. But the shading is gone if I enable scale(-1, 1, 1). What is the proper way to flip the object with respect to y-z plane without losing shading? I guess this may be caused by cu…

---

## [Using class specific vectors(?) outside class](https://discourse.processing.org/t/using-class-specific-vectors-outside-class/23269)

<div class="topic-metadata">

**Author:** [@JunQu](https://discourse.processing.org/u/JunQu)\
**Replies:** 1\
**Last updated:** [August 15, 2020, 11:04am UTC](https://discourse.processing.org/t/using-class-specific-vectors-outside-class/23269 "2020-08-15T11:04:18Z")

</div>

My problem is, that I need two different positions for a collision, that will later result in a “you died” or “game over” screen. For now. Although my two positions are in two different classes. I have tried creating a c…

---

## [How Can I crop an image in processing js with javascript?](https://discourse.processing.org/t/how-can-i-crop-an-image-in-processing-js-with-javascript/2048)

<div class="topic-metadata">

**Author:** [@donammar](https://discourse.processing.org/u/donammar)\
**Replies:** 3\
**Last updated:** [August 15, 2020, 10:16am UTC](https://discourse.processing.org/t/how-can-i-crop-an-image-in-processing-js-with-javascript/2048 "2020-08-15T10:16:49Z")

</div>

How Can I crop an image in processing js with javascript ?

---

## [Help with Error](https://discourse.processing.org/t/help-with-error/23261)

<div class="topic-metadata">

**Author:** [@doggointhehouse](https://discourse.processing.org/u/doggointhehouse)\
**Replies:** 1\
**Last updated:** [August 14, 2020, 9:00pm UTC](https://discourse.processing.org/t/help-with-error/23261 "2020-08-14T21:00:33Z")

</div>

Hello, I am trying to make a program. However, after I run the project every so often. I get this huge long error. Sometimes, it happens after I run my program once, or after a few times. java.lang.Exception at process…

---

## [Get height of text with wrapping](https://discourse.processing.org/t/get-height-of-text-with-wrapping/16087)

<div class="topic-metadata">

**Author:** [@jeffthompson](https://discourse.processing.org/u/jeffthompson)\
**Replies:** 10\
**Last updated:** [August 14, 2020, 2:23pm UTC](https://discourse.processing.org/t/get-height-of-text-with-wrapping/16087 "2020-08-14T14:23:17Z")

</div>

I love the wrapping function in text(), which does a great job. But I wish I could get the height of the block it creates so I can place further text below it. I’ve got a pretty kludgy version going here, which creates …

---

## [OpenProcessing: Cannot read property 'bind' of null](https://discourse.processing.org/t/openprocessing-cannot-read-property-bind-of-null/23245)

<div class="topic-metadata">

**Author:** [@Devolian](https://discourse.processing.org/u/Devolian)\
**Replies:** 2\
**Last updated:** [August 14, 2020, 6:19am UTC](https://discourse.processing.org/t/openprocessing-cannot-read-property-bind-of-null/23245 "2020-08-14T06:19:19Z")

</div>

I am in the process of putting a project of mine on OpenProcessing, and although it works just fine in both the Eclipse IDE and the Processing IDE, it won’t work on OpenProcessing. I have gotten through most of the erro…

---

## [How do I correctly loadStrings() from a file path on my local computer?](https://discourse.processing.org/t/how-do-i-correctly-loadstrings-from-a-file-path-on-my-local-computer/23238)

<div class="topic-metadata">

**Author:** [@CaseyJ](https://discourse.processing.org/u/CaseyJ)\
**Replies:** 2\
**Last updated:** [August 13, 2020, 10:52pm UTC](https://discourse.processing.org/t/how-do-i-correctly-loadstrings-from-a-file-path-on-my-local-computer/23238 "2020-08-13T22:52:53Z")

</div>

I have been working on reading a text file. Making progress. However, I have encountered a problem I would like some help on. That being how do I read a text file from a folder on another part of my computer? I am usin…

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

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