# Coding Questions

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

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

**Page:** 108

---

## [How to find location of random object](https://discourse.processing.org/t/how-to-find-location-of-random-object/18061)

<div class="topic-metadata">

**Author:** [@NotConsumable](https://discourse.processing.org/u/NotConsumable)\
**Replies:** 3\
**Last updated:** [February 24, 2020, 11:57am UTC](https://discourse.processing.org/t/how-to-find-location-of-random-object/18061 "2020-02-24T11:57:01Z")

</div>

so I am trying to make a hot and cold game and i have a randomly generated ellipse and i was wondering how to find the location of the ellipse in relation to my mouse so whenever i click it shows me how far away i am fro…

---

## [Repeating shapes](https://discourse.processing.org/t/repeating-shapes/18033)

<div class="topic-metadata">

**Author:** [@Mythikal](https://discourse.processing.org/u/Mythikal)\
**Replies:** 1\
**Last updated:** [February 23, 2020, 7:03am UTC](https://discourse.processing.org/t/repeating-shapes/18033 "2020-02-23T07:03:37Z")

</div>

I have a player I want to control with the arrow keys. I can’t figure out for the life of me how to stop the objects the player is made out of (an ellipse and rectangle) from repeating after moving. I’m sure the solutio…

---

## [Executing shell commands](https://discourse.processing.org/t/executing-shell-commands/18000)

<div class="topic-metadata">

**Author:** [@pandl](https://discourse.processing.org/u/pandl)\
**Replies:** 2\
**Last updated:** [February 23, 2020, 12:54am UTC](https://discourse.processing.org/t/executing-shell-commands/18000 "2020-02-23T00:54:38Z")

</div>

I’m trying to run an executable file as follows: void setup() { noLoop(); } void draw() { launch("/usr/bin/gpsbabel"); launch("/usr/bin/gpsbabel -i gpx -f /home/phil/Downloads/test3.gpx -o garmin -F /dev/ttyUSB0")…

---

## [Check boolean method in all instances for true/false](https://discourse.processing.org/t/check-boolean-method-in-all-instances-for-true-false/18022)

<div class="topic-metadata">

**Author:** [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Replies:** 12\
**Last updated:** [February 22, 2020, 11:01pm UTC](https://discourse.processing.org/t/check-boolean-method-in-all-instances-for-true-false/18022 "2020-02-22T23:01:24Z")

</div>

This is not scalable, what is the correct way to go about checking to see if the boolean method in all instances are false, rather than && each instance? for (Button b : buttons) { b.render(); if (b.isHovering(…

---

## [Saving/Storing a multidimensional array](https://discourse.processing.org/t/saving-storing-a-multidimensional-array/16391)

<div class="topic-metadata">

**Author:** [@Baz](https://discourse.processing.org/u/Baz)\
**Replies:** 4\
**Last updated:** [December 18, 2019, 12:31am UTC](https://discourse.processing.org/t/saving-storing-a-multidimensional-array/16391 "2019-12-18T00:31:54Z")

</div>

For a project of mine I want to create a function that can save a 3d double or a 2d double array such as I can recover what was inside if I restart the program. I think you can do that in JSON, but I never used it, and I…

---

## [How to increment a variable on a timer?](https://discourse.processing.org/t/how-to-increment-a-variable-on-a-timer/17984)

<div class="topic-metadata">

**Author:** [@abc](https://discourse.processing.org/u/abc)\
**Replies:** 1\
**Last updated:** [February 21, 2020, 8:50pm UTC](https://discourse.processing.org/t/how-to-increment-a-variable-on-a-timer/17984 "2020-02-21T20:50:01Z")

</div>

My goal was to make the background color change every 4 seconds, yet I can’t seem to figure out what I should use to allow my variable to continuously increase, right now the color stays the same. what do I need to add …

---

## [How to make spikes](https://discourse.processing.org/t/how-to-make-spikes/17935)

<div class="topic-metadata">

**Author:** [@DMTR](https://discourse.processing.org/u/DMTR)\
**Replies:** 31\
**Last updated:** [February 21, 2020, 2:41pm UTC](https://discourse.processing.org/t/how-to-make-spikes/17935 "2020-02-21T14:41:25Z")

</div>

Hey, i am new user in processing and java. Im creating my first game, and i need help of making randomly spawning objects that kills you if you hit it. I want those objects spawn to right and going to left (player is i…

---

## [Reversing Random Distribution](https://discourse.processing.org/t/reversing-random-distribution/17427)

<div class="topic-metadata">

**Author:** [@PhilRandom](https://discourse.processing.org/u/PhilRandom)\
**Replies:** 2\
**Last updated:** [February 20, 2020, 7:20pm UTC](https://discourse.processing.org/t/reversing-random-distribution/17427 "2020-02-20T19:20:04Z")

</div>

Hello Fellow Coders, Phil Again, It seems that I have run into another coding predicament…oops. I have successfully coded a random distribution descending code that changes color when reaching the bottom of the canvas…

---

## [Lat long to screen coordinates from database](https://discourse.processing.org/t/lat-long-to-screen-coordinates-from-database/17434)

<div class="topic-metadata">

**Author:** [@katniss0809](https://discourse.processing.org/u/katniss0809)\
**Replies:** 1\
**Last updated:** [February 20, 2020, 6:56pm UTC](https://discourse.processing.org/t/lat-long-to-screen-coordinates-from-database/17434 "2020-02-20T18:56:41Z")

</div>

I have a set of coordinates (more than 100 points) from a JDBC connection and I want to display them on Processing canvas. However, the coordinates are in latitude and longitude, e.g (42.3541, -72.1675), how can I transf…

---

## [Shape (two parameters)](https://discourse.processing.org/t/shape-two-parameters/17465)

<div class="topic-metadata">

**Author:** [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Replies:** 1\
**Last updated:** [February 19, 2020, 4:51am UTC](https://discourse.processing.org/t/shape-two-parameters/17465 "2020-02-19T04:51:50Z")

</div>

I am trying to understand shape() and its two parameters. In this simple example below I have used createShape() to make two spheres. Spheres, in my world, are three-dimensional. All is fine until I get to position the s…

---

## [Why can't use mouseX in pixels processing](https://discourse.processing.org/t/why-cant-use-mousex-in-pixels-processing/17926)

<div class="topic-metadata">

**Author:** [@fang1](https://discourse.processing.org/u/fang1)\
**Replies:** 2\
**Last updated:** [February 20, 2020, 2:39am UTC](https://discourse.processing.org/t/why-cant-use-mousex-in-pixels-processing/17926 "2020-02-20T02:39:07Z")

</div>

hello,guys! I’m sorry to borther you a little time about the problem I meeting in using mouseX,mouseY in loops of pixels location array.I find a code linkin this situation can run,but it doesn’t work on my processing sof…

---

## [Uber KML Icosahedron](https://discourse.processing.org/t/uber-kml-icosahedron/17601)

<div class="topic-metadata">

**Author:** [@HackinHarry](https://discourse.processing.org/u/HackinHarry)\
**Replies:** 2\
**Last updated:** [February 20, 2020, 1:02am UTC](https://discourse.processing.org/t/uber-kml-icosahedron/17601 "2020-02-20T01:02:05Z")

</div>

Somehow I ended up reading Uber’s articles on H3, a library they wrote to divide up their markets into hexagons. They have a github page : \[https://github.com/uber/h3/blob/master/KML/icosa.kml#L204\] that uses kml to d…

---

## [Web loadStrings](https://discourse.processing.org/t/web-loadstrings/17923)

<div class="topic-metadata">

**Author:** [@juanjoc](https://discourse.processing.org/u/juanjoc)\
**Replies:** 2\
**Last updated:** [February 19, 2020, 11:59am UTC](https://discourse.processing.org/t/web-loadstrings/17923 "2020-02-19T11:59:46Z")

</div>

Hi guys Im working with data extraction of the web. I tried to use examples like the following String\[\] rawhtml; String \[\] shows; String html; int j = 0; void setup(){ rawhtml = loadStrings("\<a href="http://www.boc…

---

## [Time synched animation](https://discourse.processing.org/t/time-synched-animation/17685)

<div class="topic-metadata">

**Author:** [@BrokenCode](https://discourse.processing.org/u/BrokenCode)\
**Replies:** 15\
**Last updated:** [February 19, 2020, 6:45pm UTC](https://discourse.processing.org/t/time-synched-animation/17685 "2020-02-19T18:45:53Z")

</div>

Hello everyone, here I’m trying to divide the screen with a grid, then fill each tile in a pre-determined amount of time: (this is the most simplified - even silly - example) float timeToConsume = 7, timeToCancelBin; in…

---

## [Creating a structure of linked tetrahedra](https://discourse.processing.org/t/creating-a-structure-of-linked-tetrahedra/16955)

<div class="topic-metadata">

**Author:** [@dauwpunt](https://discourse.processing.org/u/dauwpunt)\
**Replies:** 13\
**Last updated:** [February 19, 2020, 1:41pm UTC](https://discourse.processing.org/t/creating-a-structure-of-linked-tetrahedra/16955 "2020-02-19T13:41:12Z")

</div>

Hi there. I am trying to generate a 3D landscape of tetrahedra, so to say, and I’m having some trouble with the mathematics and coding of it. I’m also still quite new to Processing! If I am not being clear enough about s…

---

## [Problem making a wrap around loop with modulo](https://discourse.processing.org/t/problem-making-a-wrap-around-loop-with-modulo/17851)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 9\
**Last updated:** [February 19, 2020, 2:09am UTC](https://discourse.processing.org/t/problem-making-a-wrap-around-loop-with-modulo/17851 "2020-02-19T02:09:59Z")

</div>

I’m trying to make a wrap around loop with modulus. But it’s not working. Keep getting error “expecting {, found \[”. Showing function for loop appears in. If anyone can help, many thanks! color\[\]getThreeColorLerp() { …

---

## [Colour changing! (get the values to go back)](https://discourse.processing.org/t/colour-changing-get-the-values-to-go-back/17909)

<div class="topic-metadata">

**Author:** [@Mythikal](https://discourse.processing.org/u/Mythikal)\
**Replies:** 2\
**Last updated:** [February 18, 2020, 5:02pm UTC](https://discourse.processing.org/t/colour-changing-get-the-values-to-go-back/17909 "2020-02-18T17:02:44Z")

</div>

I am working on a small project and I want the stoke of the lines I’m using to slowly gradient through different colours. I have an array called “col” with three integers for each RGB value. Each are set to 255 and each…

---

## [Using mouse button events while developing sketches in the Eclipse IDE](https://discourse.processing.org/t/using-mouse-button-events-while-developing-sketches-in-the-eclipse-ide/17389)

<div class="topic-metadata">

**Author:** [@spflanze](https://discourse.processing.org/u/spflanze)\
**Replies:** 8\
**Last updated:** [February 18, 2020, 2:17pm UTC](https://discourse.processing.org/t/using-mouse-button-events-while-developing-sketches-in-the-eclipse-ide/17389 "2020-02-18T14:17:47Z")

</div>

I am developing a Processing sketch in the Eclipse IDE. I have a basic test sketch running in it. Now I need to add a menu, and in my attempt to do it I am using the information in this webpage: https://www.processing.…

---

## [NullPointerExeption when using img.get()](https://discourse.processing.org/t/nullpointerexeption-when-using-img-get/17872)

<div class="topic-metadata">

**Author:** [@Parzivalius](https://discourse.processing.org/u/Parzivalius)\
**Replies:** 9\
**Last updated:** [February 18, 2020, 8:22am UTC](https://discourse.processing.org/t/nullpointerexeption-when-using-img-get/17872 "2020-02-18T08:22:23Z")

</div>

Hey, I am trying to get the values of a pixel in an image as well as the values of the pixels around it, however the get() function is returning a null pointer exception. Most likely something wrong in my code: void fe…

---

## [Find y coordinate of point on line (given x)](https://discourse.processing.org/t/find-y-coordinate-of-point-on-line-given-x/17731)

<div class="topic-metadata">

**Author:** [@plux](https://discourse.processing.org/u/plux)\
**Replies:** 2\
**Last updated:** [February 18, 2020, 12:19pm UTC](https://discourse.processing.org/t/find-y-coordinate-of-point-on-line-given-x/17731 "2020-02-18T12:19:36Z")

</div>

Hi, I have this code which compiles but does not work as expected. I’ve translated it from some javascript I’ve found around and I’m trying to figure out where the issue is. Basically it should be fairly simple. There’…

---

## [2d shapes on the zx plane](https://discourse.processing.org/t/2d-shapes-on-the-zx-plane/17876)

<div class="topic-metadata">

**Author:** [@code\_X](https://discourse.processing.org/u/code_X)\
**Replies:** 9\
**Last updated:** [February 18, 2020, 10:23am UTC](https://discourse.processing.org/t/2d-shapes-on-the-zx-plane/17876 "2020-02-18T10:23:08Z")

</div>

So the title basically explains my question, so I’m wanting to make a program that displays a circle on the x-z plane how would I do this without a rotation statement? Is it possible? I’ve done some researching and didn’…

---

## [Completing this problem too?](https://discourse.processing.org/t/completing-this-problem-too/17907)

<div class="topic-metadata">

**Author:** [@kandrews](https://discourse.processing.org/u/kandrews)\
**Replies:** 1\
**Last updated:** [February 18, 2020, 4:06am UTC](https://discourse.processing.org/t/completing-this-problem-too/17907 "2020-02-18T04:06:06Z")

</div>

here is a second problem I don’t know how to solve, any solutions? Complete the following method. Given an array of ints, return an array with all the same elements but in reverse order. public int\[\] reverse(int\[\] nums…

---

## [Completing this problem?](https://discourse.processing.org/t/completing-this-problem/17905)

<div class="topic-metadata">

**Author:** [@kandrews](https://discourse.processing.org/u/kandrews)\
**Replies:** 4\
**Last updated:** [February 18, 2020, 4:03am UTC](https://discourse.processing.org/t/completing-this-problem/17905 "2020-02-18T04:03:22Z")

</div>

can someone solve this? Complete the longestRun method as described. Given an array of ints, determine the length of the longest “run” of values contained therein. A “run” is a group of identical values that are adjace…

---

## [How to create a diagonal line](https://discourse.processing.org/t/how-to-create-a-diagonal-line/17869)

<div class="topic-metadata">

**Author:** [@anon94203042](https://discourse.processing.org/u/anon94203042)\
**Replies:** 9\
**Last updated:** [February 18, 2020, 2:27am UTC](https://discourse.processing.org/t/how-to-create-a-diagonal-line/17869 "2020-02-18T02:27:36Z")

</div>

So I have this relatively simple code that creates a white line moving left to right across the screen. It’s similar to a “shinny” effect. However, How would I do the same effect, but have the line move diagonally from t…

---

## [How to change colors between circles when overlapping?](https://discourse.processing.org/t/how-to-change-colors-between-circles-when-overlapping/17716)

<div class="topic-metadata">

**Author:** [@kandrews](https://discourse.processing.org/u/kandrews)\
**Replies:** 3\
**Last updated:** [February 17, 2020, 4:15pm UTC](https://discourse.processing.org/t/how-to-change-colors-between-circles-when-overlapping/17716 "2020-02-17T16:15:51Z")

</div>

Circle \[\] circles = new Circle \[10\]; class Circle { float x; float y; float speed; float diam; color c; boolean valid; final int MAX\_COLOR = 255; final int MIN\_X = 50, MAX\_X = 750; final int MIN\_Y = …

---

## [Changing Colours after X iterations](https://discourse.processing.org/t/changing-colours-after-x-iterations/17881)

<div class="topic-metadata">

**Author:** [@ChrisHaz3ll](https://discourse.processing.org/u/ChrisHaz3ll)\
**Replies:** 1\
**Last updated:** [February 17, 2020, 2:48pm UTC](https://discourse.processing.org/t/changing-colours-after-x-iterations/17881 "2020-02-17T14:48:41Z")

</div>

Hi guys, So essentially I’m trying to figure out how to cycle through colours assigned within an array. I would like for every 50 frames/iterations, for the colour to change to the next one in the array (ie, 0-50 = yel…

---

## [HUD delay when is following the object](https://discourse.processing.org/t/hud-delay-when-is-following-the-object/17811)

<div class="topic-metadata">

**Author:** [@kisdfnfn](https://discourse.processing.org/u/kisdfnfn)\
**Replies:** 1\
**Last updated:** [February 17, 2020, 12:57am UTC](https://discourse.processing.org/t/hud-delay-when-is-following-the-object/17811 "2020-02-17T00:57:35Z")

</div>

“I’m brazilian then, i’m sorry, my english is very poop” I have a problem, because i’m trying to create a MMORPG with Processing, but my HUD have delay. Look: https://imgur.com/ZkFE451 draw function void draw() { b…

---

## [Save .txt file to desktop Mac](https://discourse.processing.org/t/save-txt-file-to-desktop-mac/17750)

<div class="topic-metadata">

**Author:** [@sdotjo](https://discourse.processing.org/u/sdotjo)\
**Replies:** 1\
**Last updated:** [February 17, 2020, 12:50am UTC](https://discourse.processing.org/t/save-txt-file-to-desktop-mac/17750 "2020-02-17T00:50:46Z")

</div>

Hi all, I want to save the .txt file my processing sketch outputs directly to a mac desktop. Can you suggest how I’d do that? I assume it’s within createWriter(), but I don’t know how to signify a path on mac. Here’s my…

---

## [Three faces coin flip](https://discourse.processing.org/t/three-faces-coin-flip/17518)

<div class="topic-metadata">

**Author:** [@BrokenCode](https://discourse.processing.org/u/BrokenCode)\
**Replies:** 6\
**Last updated:** [February 16, 2020, 11:46pm UTC](https://discourse.processing.org/t/three-faces-coin-flip/17518 "2020-02-16T23:46:08Z")

</div>

Hello everybody, I need to simulate a coin flip, but with three possible outcomes, method1(), method2() and method3(). But if method1() is completed, then go to method2(), but if method2() is completed then go to method…

---

## [Thick strokes overlap with stray pixels](https://discourse.processing.org/t/thick-strokes-overlap-with-stray-pixels/17865)

<div class="topic-metadata">

**Author:** [@sgt\_slaughtermelon](https://discourse.processing.org/u/sgt_slaughtermelon)\
**Replies:** 1\
**Last updated:** [February 16, 2020, 7:06pm UTC](https://discourse.processing.org/t/thick-strokes-overlap-with-stray-pixels/17865 "2020-02-16T19:06:53Z")

</div>

Okay, so I have some code that is meant to draw a series of thick strokes of random color that overlay eachother. The problem is that when they draw, they should theoretically overlap perfectly, but instead there are con…

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

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