# Coding Questions

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

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

**Page:** 142

---

## [Moving Balls & Shape Intersection](https://discourse.processing.org/t/moving-balls-shape-intersection/10792)

<div class="topic-metadata">

**Author:** [@Process321](https://discourse.processing.org/u/Process321)\
**Replies:** 1\
**Last updated:** [April 30, 2019, 6:29pm UTC](https://discourse.processing.org/t/moving-balls-shape-intersection/10792 "2019-04-30T18:29:08Z")

</div>

Hi! I am trying to find a way to bounce balls off a shape, but I am struggling to do so. I have included an expression at the end of the ‘void move()’ component, but with no success. Any help would be greatly appreciate…

---

## [Changing the size of a rectangle](https://discourse.processing.org/t/changing-the-size-of-a-rectangle/10592)

<div class="topic-metadata">

**Author:** [@S.L.C.S](https://discourse.processing.org/u/S.L.C.S)\
**Replies:** 19\
**Last updated:** [April 30, 2019, 4:01pm UTC](https://discourse.processing.org/t/changing-the-size-of-a-rectangle/10592 "2019-04-30T16:01:33Z")

</div>

I was asked to Write a program which allows the user to change the size of a rectangle with the arrow keys. The ‘R’ key should reset the size of the rectangle to 50 x 50. this is what i have so far. I believe the progra…

---

## [Very simple k-NN algorithm does not work](https://discourse.processing.org/t/very-simple-k-nn-algorithm-does-not-work/10305)

<div class="topic-metadata">

**Author:** [@anna\_mei](https://discourse.processing.org/u/anna_mei)\
**Replies:** 7\
**Last updated:** [April 30, 2019, 2:07pm UTC](https://discourse.processing.org/t/very-simple-k-nn-algorithm-does-not-work/10305 "2019-04-30T14:07:21Z")

</div>

hi everybody, today I tried to write a very simple k-NN algorithm for class. unfortunetally I did not succeed so far. can someone see where the code is erroneous? my best guess is that the error occurs in the colour ass…

---

## [Get just one channel of RGB photos?](https://discourse.processing.org/t/get-just-one-channel-of-rgb-photos/10732)

<div class="topic-metadata">

**Author:** [@darinb](https://discourse.processing.org/u/darinb)\
**Replies:** 11\
**Last updated:** [April 29, 2019, 10:37pm UTC](https://discourse.processing.org/t/get-just-one-channel-of-rgb-photos/10732 "2019-04-29T22:37:30Z")

</div>

Hello, I’m stuck… If I have an RGB image how to I display just the red channel (or just the blue, or green)? If I wanted to show a combination of two channels is there a faster way (faster as in computer speed) to sho…

---

## [Where to put csv files in Processing 3?](https://discourse.processing.org/t/where-to-put-csv-files-in-processing-3/10753)

<div class="topic-metadata">

**Author:** [@Seyfi](https://discourse.processing.org/u/Seyfi)\
**Replies:** 12\
**Last updated:** [April 29, 2019, 2:33pm UTC](https://discourse.processing.org/t/where-to-put-csv-files-in-processing-3/10753 "2019-04-29T14:33:32Z")

</div>

Hello I am new to Processing. I want to parse a csv file but it does not get it. Can you help me please? Thanks My code is :slight\_smile: Table table; void setup() { table = loadTable("C:/Users/Seyfi/Desktop/pr…

---

## [Csv does not exist or could not be read NullPointerException](https://discourse.processing.org/t/csv-does-not-exist-or-could-not-be-read-nullpointerexception/10785)

<div class="topic-metadata">

**Author:** [@peterf98](https://discourse.processing.org/u/peterf98)\
**Replies:** 3\
**Last updated:** [April 30, 2019, 6:18am UTC](https://discourse.processing.org/t/csv-does-not-exist-or-could-not-be-read-nullpointerexception/10785 "2019-04-30T06:18:05Z")

</div>

---

## [How to do a stationary scale animation?](https://discourse.processing.org/t/how-to-do-a-stationary-scale-animation/10627)

<div class="topic-metadata">

**Author:** [@karatecake](https://discourse.processing.org/u/karatecake)\
**Replies:** 4\
**Last updated:** [April 29, 2019, 10:48pm UTC](https://discourse.processing.org/t/how-to-do-a-stationary-scale-animation/10627 "2019-04-29T22:48:01Z")

</div>

I have 4 mushroom shapes I’d like to grow and shrink while staying in their current positions. I’ve tried a few kinds of code, but it ends up moving my mushrooms away from where I placed them. Here are each of my mushroo…

---

## [Collect circle using square](https://discourse.processing.org/t/collect-circle-using-square/10773)

<div class="topic-metadata">

**Author:** [@Hello](https://discourse.processing.org/u/Hello)\
**Replies:** 5\
**Last updated:** [April 30, 2019, 5:15am UTC](https://discourse.processing.org/t/collect-circle-using-square/10773 "2019-04-30T05:15:07Z")

</div>

so far i have this and i need help in making the circle get collected int x; int y; float circleX; float circleY; int points = 0; void setup(){ textSize(20); size (400, 400); x = width/2; y = height/2; …

---

## [Menu Screen Help](https://discourse.processing.org/t/menu-screen-help/10766)

<div class="topic-metadata">

**Author:** [@luooke](https://discourse.processing.org/u/luooke)\
**Replies:** 2\
**Last updated:** [April 30, 2019, 1:36am UTC](https://discourse.processing.org/t/menu-screen-help/10766 "2019-04-30T01:36:09Z")

</div>

I’m having trouble with my menu screen for a game I’m trying to code. When I click the mouse, it isn’t taking me to the next screen (i.e when I click levels it doesn’t show the levels screen.) Can anyone help me? Thank y…

---

## [Maze Game trying to display scary image](https://discourse.processing.org/t/maze-game-trying-to-display-scary-image/10641)

<div class="topic-metadata">

**Author:** [@GuerillaGirl](https://discourse.processing.org/u/GuerillaGirl)\
**Replies:** 4\
**Last updated:** [April 29, 2019, 8:35pm UTC](https://discourse.processing.org/t/maze-game-trying-to-display-scary-image/10641 "2019-04-29T20:35:41Z")

</div>

Hey - we are trying to get this maze to display a scary image if a player hits the edge but everything we have tried is not working. We pasted the code below. We thought if we used an if statement inside of draw it would…

---

## [Slide Show Animation](https://discourse.processing.org/t/slide-show-animation/10595)

<div class="topic-metadata">

**Author:** [@jcop](https://discourse.processing.org/u/jcop)\
**Replies:** 2\
**Last updated:** [April 29, 2019, 4:50pm UTC](https://discourse.processing.org/t/slide-show-animation/10595 "2019-04-29T16:50:27Z")

</div>

PImage france2; PImage france3; PImage france4; void setup(){ size(1000,600); smooth(); france2 = loadImage("New Yotk.jpg"); france3 = loadImage("france.jpg"); france4 = loadImage("madrid.jpg"); } void draw(){ ba…

---

## [How to adapt my existing methods that write to the screen to work with PGraphics instead - when required?](https://discourse.processing.org/t/how-to-adapt-my-existing-methods-that-write-to-the-screen-to-work-with-pgraphics-instead-when-required/10609)

<div class="topic-metadata">

**Author:** [@CharlieCheeseCake](https://discourse.processing.org/u/CharlieCheeseCake)\
**Replies:** 4\
**Last updated:** [April 29, 2019, 3:39pm UTC](https://discourse.processing.org/t/how-to-adapt-my-existing-methods-that-write-to-the-screen-to-work-with-pgraphics-instead-when-required/10609 "2019-04-29T15:39:21Z")

</div>

I’m able to successfully draw to the screen using standard methods such as : stroke, line & fill. Similarly I’m able to draw to a graphics buffer, thus: PGraphics buff; buff = createGraphics( 200, 200 ); buff.beginDraw…

---

## [Need help with an assignment from school](https://discourse.processing.org/t/need-help-with-an-assignment-from-school/10584)

<div class="topic-metadata">

**Author:** [@S.L.C.S](https://discourse.processing.org/u/S.L.C.S)\
**Replies:** 9\
**Last updated:** [April 29, 2019, 2:02pm UTC](https://discourse.processing.org/t/need-help-with-an-assignment-from-school/10584 "2019-04-29T14:02:04Z")

</div>

Hello everyone, I was given the assignment to create a program that allows the user to collect coins. Randomly generate a yellow circle on the screen, the user must move a square to meet the circle. Once they get their …

---

## [How to create randomly assigned array?](https://discourse.processing.org/t/how-to-create-randomly-assigned-array/10744)

<div class="topic-metadata">

**Author:** [@danmarty](https://discourse.processing.org/u/danmarty)\
**Replies:** 3\
**Last updated:** [April 29, 2019, 1:27pm UTC](https://discourse.processing.org/t/how-to-create-randomly-assigned-array/10744 "2019-04-29T13:27:56Z")

</div>

Hi everyone, I’m still very new to processing, and I want to be able to create an array (or class?) of 7 different floor types I have made out of rectangles. Below is the code for these different floor types, in the sta…

---

## [Modified Circle Collision to Rectangles](https://discourse.processing.org/t/modified-circle-collision-to-rectangles/10720)

<div class="topic-metadata">

**Author:** [@chensley53](https://discourse.processing.org/u/chensley53)\
**Replies:** 1\
**Last updated:** [April 29, 2019, 9:12am UTC](https://discourse.processing.org/t/modified-circle-collision-to-rectangles/10720 "2019-04-29T09:12:11Z")

</div>

I found the code someone posted of Circle Collision and was trying to modify it to be rectangles and it’s all working well besides the collision detection being slightly off between the two rectangles. void checkCollisi…

---

## [What;s wrong with my code? SOS assignment help](https://discourse.processing.org/t/what-s-wrong-with-my-code-sos-assignment-help/4301)

<div class="topic-metadata">

**Author:** [@njdsvdsjVNsdo](https://discourse.processing.org/u/njdsvdsjVNsdo)\
**Replies:** 2\
**Last updated:** [October 10, 2018, 1:46am UTC](https://discourse.processing.org/t/what-s-wrong-with-my-code-sos-assignment-help/4301 "2018-10-10T01:46:42Z")

</div>

I’m supposed to develop an algorithm to determine what mortgage rate is available based on the type and duration of the mortgage desired. This is what I currently have: import javax.swing.JOptionPane; String inputX; in…

---

## [Need help with generative art](https://discourse.processing.org/t/need-help-with-generative-art/10727)

<div class="topic-metadata">

**Author:** [@tiwis](https://discourse.processing.org/u/tiwis)\
**Replies:** 1\
**Last updated:** [April 29, 2019, 2:22am UTC](https://discourse.processing.org/t/need-help-with-generative-art/10727 "2019-04-29T02:22:04Z")

</div>

Hello, my name is Matías, i’m from Argentina and this is my first post on this awersome forum. Today, i’m working with generative art and the problem is that i’m “painting” the background with the mouseX and mouseY posi…

---

## [Trouble with gravity and ending game](https://discourse.processing.org/t/trouble-with-gravity-and-ending-game/10729)

<div class="topic-metadata">

**Author:** [@NeedHelp](https://discourse.processing.org/u/NeedHelp)\
**Replies:** 2\
**Last updated:** [April 29, 2019, 1:57am UTC](https://discourse.processing.org/t/trouble-with-gravity-and-ending-game/10729 "2019-04-29T01:57:40Z")

</div>

I’m trying to make a game for my Processing class. It is due tomorrow morning and is almost completely finished, but I am having trouble triggering the end game screen when the ball leaves the screen. I also need the bal…

---

## [Color map from grayscale](https://discourse.processing.org/t/color-map-from-grayscale/10656)

<div class="topic-metadata">

**Author:** [@fun](https://discourse.processing.org/u/fun)\
**Replies:** 6\
**Last updated:** [April 28, 2019, 8:43pm UTC](https://discourse.processing.org/t/color-map-from-grayscale/10656 "2019-04-28T20:43:19Z")

</div>

I am looking for a way to create a heat map from a sequence of gray scale images with nice gray scale blobs. The heat map should look like these maps you know from eyetracking. Starting with black, blue, green and then …

---

## [quadraticVertex bezierVertex give different shape](https://discourse.processing.org/t/quadraticvertex-beziervertex-give-different-shape/10712)

<div class="topic-metadata">

**Author:** [@IanM](https://discourse.processing.org/u/IanM)\
**Replies:** 3\
**Last updated:** [April 28, 2019, 1:50pm UTC](https://discourse.processing.org/t/quadraticvertex-beziervertex-give-different-shape/10712 "2019-04-28T13:50:24Z")

</div>

Hi I was expecting these calls to give the same shape, but the curves are different. I was testing and not getting the expected results with quadraticVertex, hence this test using duplicate control points in the bezierV…

---

## [Processing beginner unable to fix NPE](https://discourse.processing.org/t/processing-beginner-unable-to-fix-npe/10679)

<div class="topic-metadata">

**Author:** [@danmarty](https://discourse.processing.org/u/danmarty)\
**Replies:** 7\
**Last updated:** [April 28, 2019, 10:35am UTC](https://discourse.processing.org/t/processing-beginner-unable-to-fix-npe/10679 "2019-04-28T10:35:08Z")

</div>

Hi everyone, As a preface, I’m a complete beginner to all forms of programming before my university unit I’m currently working taking part in. I’m working on a game design for a university project, but my progress is c…

---

## [Help with a "Drawing" App](https://discourse.processing.org/t/help-with-a-drawing-app/10688)

<div class="topic-metadata">

**Author:** [@l1osar](https://discourse.processing.org/u/l1osar)\
**Replies:** 2\
**Last updated:** [April 28, 2019, 1:18am UTC](https://discourse.processing.org/t/help-with-a-drawing-app/10688 "2019-04-28T01:18:16Z")

</div>

Hello! I’m learnig processing, so I had the idea of creating an app to work like paint or Ilustrator. I figured out a lot of stuff, but couldn’t realize how to “save” the current drawing. I want to create a different sc…

---

## [Aligning a text correctly with rotation](https://discourse.processing.org/t/aligning-a-text-correctly-with-rotation/10692)

<div class="topic-metadata">

**Author:** [@fedpep](https://discourse.processing.org/u/fedpep)\
**Replies:** 4\
**Last updated:** [April 27, 2019, 10:55pm UTC](https://discourse.processing.org/t/aligning-a-text-correctly-with-rotation/10692 "2019-04-27T22:55:01Z")

</div>

Hello, I’m working on a sketch that displays a radar chart. I am satisfied by the result but I’m struggling having the labels aligning correctly. int lineLength = 300; int\[\] values = { 10, 20, 30, 40, 50, 60, 70, 80, 90…

---

## [Assignment / Extra credit program](https://discourse.processing.org/t/assignment-extra-credit-program/10680)

<div class="topic-metadata">

**Author:** [@S.L.C.S](https://discourse.processing.org/u/S.L.C.S)\
**Replies:** 10\
**Last updated:** [April 27, 2019, 4:53pm UTC](https://discourse.processing.org/t/assignment-extra-credit-program/10680 "2019-04-27T16:53:01Z")

</div>

I was given a task to create a digital landscape! with the following criteria Criteria: ● At least 3 different shapes used ● At least 3 different colors used ● 1 custom shape ● Minimum of 6 elements (ie tree, house,…

---

## [Memory error at 1000mb when trying to save an int variable](https://discourse.processing.org/t/memory-error-at-1000mb-when-trying-to-save-an-int-variable/10666)

<div class="topic-metadata">

**Author:** [@LHACKS](https://discourse.processing.org/u/LHACKS)\
**Replies:** 1\
**Last updated:** [April 27, 2019, 11:23am UTC](https://discourse.processing.org/t/memory-error-at-1000mb-when-trying-to-save-an-int-variable/10666 "2019-04-27T11:23:23Z")

</div>

So I was trying save the high score for my game and it says memory error even if I changed it to 1000Mb = 1 Gb. I’m only going to put the code for the saving process here. The high score variable has been on 40 and on 12…

---

## [Json: folder tree recursively: Feedback please](https://discourse.processing.org/t/json-folder-tree-recursively-feedback-please/10542)

<div class="topic-metadata">

**Author:** [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Replies:** 2\
**Last updated:** [April 27, 2019, 8:38am UTC](https://discourse.processing.org/t/json-folder-tree-recursively-feedback-please/10542 "2019-04-27T08:38:55Z")

</div>

Hello all, I made a sketch where you can select a folder and it makes a json file with all folders recursively as children and sub-children. Could somebody have a look and tell me whether that’s the proper way to do it…

---

## [NullPointerException when calling save() after surface.setSize() in P2D](https://discourse.processing.org/t/nullpointerexception-when-calling-save-after-surface-setsize-in-p2d/10367)

<div class="topic-metadata">

**Author:** [@blakej](https://discourse.processing.org/u/blakej)\
**Replies:** 13\
**Last updated:** [April 25, 2019, 10:57pm UTC](https://discourse.processing.org/t/nullpointerexception-when-calling-save-after-surface-setsize-in-p2d/10367 "2019-04-25T22:57:04Z")

</div>

Hi all, I’m getting a NullPointerException when trying to use save() in conjunction with surface.setSize() and the P2D renderer. Here’s a simplified version of my code: void settings() { size(768, 512, P2D); } void…

---

## [Array syntax in this code does not hold y variable](https://discourse.processing.org/t/array-syntax-in-this-code-does-not-hold-y-variable/10637)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 2\
**Last updated:** [April 25, 2019, 6:29pm UTC](https://discourse.processing.org/t/array-syntax-in-this-code-does-not-hold-y-variable/10637 "2019-04-25T18:29:41Z")

</div>

Referring to Dan Shiffman book Learning Processing Ch 9 Arrays ~ex 9-12~ p.182-3 The y variable – random(height) – in the “Zoogies” constructor in setup does not maintain the random y variable assigned. (in contrast, th…

---

## [Trying to do an animation, how can I make the mushroom go from closed to open?](https://discourse.processing.org/t/trying-to-do-an-animation-how-can-i-make-the-mushroom-go-from-closed-to-open/10614)

<div class="topic-metadata">

**Author:** [@karatecake](https://discourse.processing.org/u/karatecake)\
**Replies:** 2\
**Last updated:** [April 25, 2019, 2:18pm UTC](https://discourse.processing.org/t/trying-to-do-an-animation-how-can-i-make-the-mushroom-go-from-closed-to-open/10614 "2019-04-25T14:18:50Z")

</div>

My animation is a mushroom with a closed cap that when clicked opens like an umbrella exposing the stalk more. I have no idea where to go from here because my professor has not given us enough information. There is much …

---

## [Error message in this Array problem i don't know how to resolve](https://discourse.processing.org/t/error-message-in-this-array-problem-i-dont-know-how-to-resolve/10611)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 5\
**Last updated:** [April 25, 2019, 8:11am UTC](https://discourse.processing.org/t/error-message-in-this-array-problem-i-dont-know-how-to-resolve/10611 "2019-04-25T08:11:11Z")

</div>

In Dan Shiffman’s book Learning Processing, p. 179, example 9-10 I have typed in the code for this example, and have carefully checked to make sure no keystroking errors. However I keep getting errors in the void rollov…

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

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