# Coding Questions

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

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

**Page:** 134

---

## [Picture is flickering when collision checked](https://discourse.processing.org/t/picture-is-flickering-when-collision-checked/12414)

<div class="topic-metadata">

**Author:** [@SunnyPlayz](https://discourse.processing.org/u/SunnyPlayz)\
**Replies:** 1\
**Last updated:** [July 1, 2019, 12:21am UTC](https://discourse.processing.org/t/picture-is-flickering-when-collision-checked/12414 "2019-07-01T00:21:42Z")

</div>

Hi, I have made it check for collision and the code works but it makes all the image flicker when it runs. Do i need to change the collision checker to not make images flicker? boolean checkCollision(int bLeft, int bRig…

---

## [Scrolling problem with a bar graph](https://discourse.processing.org/t/scrolling-problem-with-a-bar-graph/12183)

<div class="topic-metadata">

**Author:** [@wordcounter](https://discourse.processing.org/u/wordcounter)\
**Replies:** 4\
**Last updated:** [June 30, 2019, 5:40pm UTC](https://discourse.processing.org/t/scrolling-problem-with-a-bar-graph/12183 "2019-06-30T17:40:02Z")

</div>

Hi! I’m new to processing and working on a data visualization of word frequency in a corpus of poems, shown through a bar graph. My problem is I can’t seem to figure out how to add vertical scroll/panning to my sketch to…

---

## [Make a method to get area, result should be 2000→ println(rect1.sumArea(rect2))](https://discourse.processing.org/t/make-a-method-to-get-area-result-should-be-2000-println-rect1-sumarea-rect2/12402)

<div class="topic-metadata">

**Author:** [@henry](https://discourse.processing.org/u/henry)\
**Replies:** 4\
**Last updated:** [June 30, 2019, 12:03pm UTC](https://discourse.processing.org/t/make-a-method-to-get-area-result-should-be-2000-println-rect1-sumarea-rect2/12402 "2019-06-30T12:03:54Z")

</div>

MyRect rect1; MyRect rect2; void setup(){ size(240,120); rectMode(CENTER); rect1=new MyRect(20,20,40,30); rect2=new MyRect(30,50,20,40); println(rect1.sumArea(rect2)); } void draw(){ rect1.drawShape(2); …

---

## [How to get multiple image pixel array](https://discourse.processing.org/t/how-to-get-multiple-image-pixel-array/12382)

<div class="topic-metadata">

**Author:** [@The\_nish](https://discourse.processing.org/u/The_nish)\
**Replies:** 2\
**Last updated:** [June 30, 2019, 4:31am UTC](https://discourse.processing.org/t/how-to-get-multiple-image-pixel-array/12382 "2019-06-30T04:31:06Z")

</div>

…post is deleted

---

## [Problem with keyPressed when drawing a square](https://discourse.processing.org/t/problem-with-keypressed-when-drawing-a-square/12389)

<div class="topic-metadata">

**Author:** [@karan26](https://discourse.processing.org/u/karan26)\
**Replies:** 1\
**Last updated:** [June 29, 2019, 10:06pm UTC](https://discourse.processing.org/t/problem-with-keypressed-when-drawing-a-square/12389 "2019-06-29T22:06:17Z")

</div>

hiii,i am trying to add a square to the canvas when a key is pressed and i want it to remain on the canvas when the key is released . but it disappears when is released the key .can anybody help me?? here is my code i…

---

## [Why is it that when I zoom in the frameRate drops massively?](https://discourse.processing.org/t/why-is-it-that-when-i-zoom-in-the-framerate-drops-massively/12349)

<div class="topic-metadata">

**Author:** [@LoliProcessor](https://discourse.processing.org/u/LoliProcessor)\
**Replies:** 9\
**Last updated:** [June 29, 2019, 1:21pm UTC](https://discourse.processing.org/t/why-is-it-that-when-i-zoom-in-the-framerate-drops-massively/12349 "2019-06-29T13:21:58Z")

</div>

I wrote a game where when you increase the zoom factor by even the slightest, the frameRate drops massively until it barely renders the next frame anymore; weirdly, that doesn’t occur when zooming out. reversely, zoomin…

---

## [Odd behaviour when using copy()](https://discourse.processing.org/t/odd-behaviour-when-using-copy/12375)

<div class="topic-metadata">

**Author:** [@lsk](https://discourse.processing.org/u/lsk)\
**Replies:** 2\
**Last updated:** [June 29, 2019, 1:26pm UTC](https://discourse.processing.org/t/odd-behaviour-when-using-copy/12375 "2019-06-29T13:26:54Z")

</div>

I create a PGraphics object pg1 and set its color to blue. Then I want to copy a tile from pg1 to a PImage object the size of 1 tile. I use pImg.copy(src, sx, sy, sw, sh, dx, dy, dw, dh); This should - if I understood …

---

## [I want to count the number of occurrences of a name of "sato"](https://discourse.processing.org/t/i-want-to-count-the-number-of-occurrences-of-a-name-of-sato/12257)

<div class="topic-metadata">

**Author:** [@henry](https://discourse.processing.org/u/henry)\
**Replies:** 17\
**Last updated:** [June 29, 2019, 10:16am UTC](https://discourse.processing.org/t/i-want-to-count-the-number-of-occurrences-of-a-name-of-sato/12257 "2019-06-29T10:16:02Z")

</div>

what’s wrong with my code? It should be print out “4” for “sato”'s appearance times String\[\]lines= loadStrings("data.txt"); String\[\]sato= loadStrings("keyword.txt"); int count=0; for (int i=0; i\<lines.length; i++) { …

---

## [How to make grid of image pixels in nested loop](https://discourse.processing.org/t/how-to-make-grid-of-image-pixels-in-nested-loop/12356)

<div class="topic-metadata">

**Author:** [@The\_nish](https://discourse.processing.org/u/The_nish)\
**Replies:** 2\
**Last updated:** [June 28, 2019, 7:57pm UTC](https://discourse.processing.org/t/how-to-make-grid-of-image-pixels-in-nested-loop/12356 "2019-06-28T19:57:32Z")

</div>

i have image pixel length from 0 to 10000 . i want to make a grid of 100\*100 in nested loop. please tell me how can i do that… for (int y=0; y\<img.height; y++) { for (int x=0; x\<img.width; x++) { int…

---

## [How to start an animation again from the beginning at specific point](https://discourse.processing.org/t/how-to-start-an-animation-again-from-the-beginning-at-specific-point/12232)

<div class="topic-metadata">

**Author:** [@TurboUrpo](https://discourse.processing.org/u/TurboUrpo)\
**Replies:** 6\
**Last updated:** [June 28, 2019, 3:27pm UTC](https://discourse.processing.org/t/how-to-start-an-animation-again-from-the-beginning-at-specific-point/12232 "2019-06-28T15:27:44Z")

</div>

Yep, that’s the thing where I need some help and advice. How to set it the way that it runs the animation from beginning, and at the specific point the animation starts again from the beginning and runs again at the same…

---

## [Code for artDCGAN?](https://discourse.processing.org/t/code-for-artdcgan/287)

<div class="topic-metadata">

**Author:** [@ezyryder](https://discourse.processing.org/u/ezyryder)\
**Replies:** 6\
**Last updated:** [June 28, 2019, 1:01am UTC](https://discourse.processing.org/t/code-for-artdcgan/287 "2019-06-28T01:01:19Z")

</div>

Hello! I am a complete newbie to coding and Processing and I need some help with my art project. So I was wondering if I can make one generative digital painting based on few of my paintings (something like this, nude…

---

## [Issue when using loadShape()](https://discourse.processing.org/t/issue-when-using-loadshape/12216)

<div class="topic-metadata">

**Author:** [@macbrayne](https://discourse.processing.org/u/macbrayne)\
**Replies:** 4\
**Last updated:** [June 26, 2019, 9:49pm UTC](https://discourse.processing.org/t/issue-when-using-loadshape/12216 "2019-06-26T21:49:05Z")

</div>

Hello there! I’m currently migrating a game I’m currently writing from .png to .svg for better scaling however I’m having issues with using a certain icon from material.io (Settings icon).Processing throws an error when…

---

## [Downloading CSV from web server](https://discourse.processing.org/t/downloading-csv-from-web-server/12286)

<div class="topic-metadata">

**Author:** [@pablogott](https://discourse.processing.org/u/pablogott)\
**Replies:** 5\
**Last updated:** [June 26, 2019, 8:20pm UTC](https://discourse.processing.org/t/downloading-csv-from-web-server/12286 "2019-06-26T20:20:38Z")

</div>

I have a CSV that constantly gets updated on a web server. How can I download the data? I already have code for processing if the data exists locally, but I’d rather not have to store it locally and just read it from the…

---

## [Problem with displaying a PShape](https://discourse.processing.org/t/problem-with-displaying-a-pshape/12267)

<div class="topic-metadata">

**Author:** [@elijb](https://discourse.processing.org/u/elijb)\
**Replies:** 2\
**Last updated:** [June 26, 2019, 6:56pm UTC](https://discourse.processing.org/t/problem-with-displaying-a-pshape/12267 "2019-06-26T18:56:12Z")

</div>

ShapeMaker sm; void setup() { size(600, 600, P3D); sm = new ShapeMaker(); sm.makeCylinder(100, 100, 200, 40); //sm.makeEllipse(200); } void draw() { background(0); translate(width/2, height/2); sm.displayS…

---

## [Sharing objects between multiple PApplets - Processing in Eclipse - runSketch()](https://discourse.processing.org/t/sharing-objects-between-multiple-papplets-processing-in-eclipse-runsketch/9427)

<div class="topic-metadata">

**Author:** [@rgthings](https://discourse.processing.org/u/rgthings)\
**Replies:** 7\
**Last updated:** [June 26, 2019, 6:11pm UTC](https://discourse.processing.org/t/sharing-objects-between-multiple-papplets-processing-in-eclipse-runsketch/9427 "2019-06-26T18:11:40Z")

</div>

hello, I am using Processing (3.2.3) in Eclipse and I have managed to produce a second PApplet window using using runSketch(). I would like to use the second window to control what goes on in the first (and vice versa a…

---

## [Shader code for show selected part of image - OpenTk](https://discourse.processing.org/t/shader-code-for-show-selected-part-of-image-opentk/12316)

<div class="topic-metadata">

**Author:** [@NSDS](https://discourse.processing.org/u/NSDS)\
**Replies:** 0\
**Last updated:** [June 26, 2019, 6:09pm UTC](https://discourse.processing.org/t/shader-code-for-show-selected-part-of-image-opentk/12316 "2019-06-26T18:09:22Z")

</div>

I want to show second half portion of an image in my glcontrol, in a condition that only 0.7 to 0. 9 of second half is want to see in glControl. For that I have done like below. But it shows portion of first half of imag…

---

## [Turn X,Y, Z mouse tracker into 3D CAD file?](https://discourse.processing.org/t/turn-x-y-z-mouse-tracker-into-3d-cad-file/12275)

<div class="topic-metadata">

**Author:** [@sdotjo](https://discourse.processing.org/u/sdotjo)\
**Replies:** 10\
**Last updated:** [June 26, 2019, 1:18pm UTC](https://discourse.processing.org/t/turn-x-y-z-mouse-tracker-into-3d-cad-file/12275 "2019-06-26T13:18:14Z")

</div>

Hello! I am working on a project to be able to “draw” with a 3D clay printer. Right now I have a sketch that draws X,Y with mouse movement and Z with time elapsed. I want to be able to export this line as a CAD file so…

---

## [Random Word Picker](https://discourse.processing.org/t/random-word-picker/10619)

<div class="topic-metadata">

**Author:** [@mariamalz](https://discourse.processing.org/u/mariamalz)\
**Replies:** 7\
**Last updated:** [June 26, 2019, 12:53pm UTC](https://discourse.processing.org/t/random-word-picker/10619 "2019-06-26T12:53:37Z")

</div>

So I just want to create a simple random word picker that can display one word every time the program is run. So far I have this code but it keeps generating words after the first one has popped up, and currently there …

---

## [I cant create a new Object when the old one hits a certain x value](https://discourse.processing.org/t/i-cant-create-a-new-object-when-the-old-one-hits-a-certain-x-value/11820)

<div class="topic-metadata">

**Author:** [@sc4p3g0a7](https://discourse.processing.org/u/sc4p3g0a7)\
**Replies:** 4\
**Last updated:** [June 25, 2019, 8:19pm UTC](https://discourse.processing.org/t/i-cant-create-a-new-object-when-the-old-one-hits-a-certain-x-value/11820 "2019-06-25T20:19:20Z")

</div>

Hello, so i am making a game, and there are two main objects, there is you, and the obstacle. i want to crate a new obstacle, when the previous one gets to a certain space, Here is the code for the obstacle PVector lo…

---

## [Mouse position is tracked beyond sketch window while dragging](https://discourse.processing.org/t/mouse-position-is-tracked-beyond-sketch-window-while-dragging/12283)

<div class="topic-metadata">

**Author:** [@gyula](https://discourse.processing.org/u/gyula)\
**Replies:** 0\
**Last updated:** [June 25, 2019, 1:23pm UTC](https://discourse.processing.org/t/mouse-position-is-tracked-beyond-sketch-window-while-dragging/12283 "2019-06-25T13:23:21Z")

</div>

This is not a question but a statement. According to the reference, Processing can only track mouseX and mouseY when the pointer is over the current window. Once the mouse moves away from the window, mouseX and mouseY w…

---

## [How do I add score to my game?](https://discourse.processing.org/t/how-do-i-add-score-to-my-game/12246)

<div class="topic-metadata">

**Author:** [@rahul321](https://discourse.processing.org/u/rahul321)\
**Replies:** 7\
**Last updated:** [June 25, 2019, 10:28am UTC](https://discourse.processing.org/t/how-do-i-add-score-to-my-game/12246 "2019-06-25T10:28:53Z")

</div>

I’m new to processing and have been trying to make a game in which the character moves to the coordinates of mouse click and then stays there until it is called again. I have a “food” which moves to a random location whe…

---

## [PImage garbage not being properly collected](https://discourse.processing.org/t/pimage-garbage-not-being-properly-collected/12252)

<div class="topic-metadata">

**Author:** [@n055](https://discourse.processing.org/u/n055)\
**Replies:** 8\
**Last updated:** [June 24, 2019, 5:48pm UTC](https://discourse.processing.org/t/pimage-garbage-not-being-properly-collected/12252 "2019-06-24T17:48:11Z")

</div>

Howdy. I’m making a display intended to be constantly running on a TV as a sort of information Plaque. I utilize PImage objects as I have a folder of pictures I wish to display as a slideshow, and I am aware that those …

---

## [Float 2D Array Data Limit](https://discourse.processing.org/t/float-2d-array-data-limit/12189)

<div class="topic-metadata">

**Author:** [@SmallSalamander](https://discourse.processing.org/u/SmallSalamander)\
**Replies:** 11\
**Last updated:** [June 23, 2019, 10:41pm UTC](https://discourse.processing.org/t/float-2d-array-data-limit/12189 "2019-06-23T22:41:20Z")

</div>

I have a problem with my code where I added 2.25 million numbers to a float 2D array, and depending on the computer the program either does not run or gives a string of errors. I was wondering if there is a way to either…

---

## [Unknown class through a function](https://discourse.processing.org/t/unknown-class-through-a-function/12236)

<div class="topic-metadata">

**Author:** [@FlyingApple](https://discourse.processing.org/u/FlyingApple)\
**Replies:** 2\
**Last updated:** [June 23, 2019, 9:40pm UTC](https://discourse.processing.org/t/unknown-class-through-a-function/12236 "2019-06-23T21:40:03Z")

</div>

void collision(Player player) { for (Wall wall : walls) { //find collision between player and wall, if they collide, stop player movement Is it possible for the example above to have an unknown class passed throu…

---

## [Using shape() in P2D can throw OutOfMemory and ArrayIndexOutOfBoundsException](https://discourse.processing.org/t/using-shape-in-p2d-can-throw-outofmemory-and-arrayindexoutofboundsexception/12242)

<div class="topic-metadata">

**Author:** [@macbrayne](https://discourse.processing.org/u/macbrayne)\
**Replies:** 6\
**Last updated:** [June 23, 2019, 4:50pm UTC](https://discourse.processing.org/t/using-shape-in-p2d-can-throw-outofmemory-and-arrayindexoutofboundsexception/12242 "2019-06-23T16:50:30Z")

</div>

Hello! When trying to display a specific svg using shape the P2D renderer spits out a OutOfMemory error. I think this might be a bug. java.lang.ArrayIndexOutOfBoundsException: 200 at jogamp.opengl.glu.tessellator.Prio…

---

## [What's wrong with this code? HELP I want to code to like the picture I've added of](https://discourse.processing.org/t/whats-wrong-with-this-code-help-i-want-to-code-to-like-the-picture-ive-added-of/12249)

<div class="topic-metadata">

**Author:** [@henry](https://discourse.processing.org/u/henry)\
**Replies:** 4\
**Last updated:** [June 23, 2019, 11:28am UTC](https://discourse.processing.org/t/whats-wrong-with-this-code-help-i-want-to-code-to-like-the-picture-ive-added-of/12249 "2019-06-23T11:28:54Z")

</div>

size(300, 300); int\[\]data={50, 100, 30, 120, 40, 70, 150}; int max=data\[0\]; int min=data\[0\]; for (int i=0; i\<data.length; i++) { fill(255); rect(10+15\*i, 10, 10, data\[i\]); if(max\<data\[i\]) { max=data\[i\]; …

---

## [Convert double to bytes](https://discourse.processing.org/t/convert-double-to-bytes/12154)

<div class="topic-metadata">

**Author:** [@x13420x](https://discourse.processing.org/u/x13420x)\
**Replies:** 4\
**Last updated:** [June 22, 2019, 11:36pm UTC](https://discourse.processing.org/t/convert-double-to-bytes/12154 "2019-06-22T23:36:38Z")

</div>

I need to convert a single array of doubles to 8 arrays of bytes to save…but not sure this is possible…currently I am converting to float then to str…to save as txt…but there is some loss with this…I would prefer to pres…

---

## [saveFrame not advancing frame count](https://discourse.processing.org/t/saveframe-not-advancing-frame-count/12060)

<div class="topic-metadata">

**Author:** [@PixelMx](https://discourse.processing.org/u/PixelMx)\
**Replies:** 6\
**Last updated:** [June 22, 2019, 4:49pm UTC](https://discourse.processing.org/t/saveframe-not-advancing-frame-count/12060 "2019-06-22T16:49:02Z")

</div>

Good morning. My processing has been acting up. First, it didn’t follow the size command and was creating sketches at 4K no matter what. I fixed this by opening an older version of Processing and running the sketch, then…

---

## [Screen capturer](https://discourse.processing.org/t/screen-capturer/12059)

<div class="topic-metadata">

**Author:** [@samolet4e](https://discourse.processing.org/u/samolet4e)\
**Replies:** 4\
**Last updated:** [June 22, 2019, 2:57pm UTC](https://discourse.processing.org/t/screen-capturer/12059 "2019-06-22T14:57:16Z")

</div>

Hello. I would like to discuss an issue related to a screen capturing program. The following code is capable of screen recording and overlaying the mouse cursor: import java.awt.Robot; import java.awt.image.BufferedImag…

---

## [Problems with background in draw();](https://discourse.processing.org/t/problems-with-background-in-draw/12218)

<div class="topic-metadata">

**Author:** [@wordcounter](https://discourse.processing.org/u/wordcounter)\
**Replies:** 3\
**Last updated:** [June 22, 2019, 10:35am UTC](https://discourse.processing.org/t/problems-with-background-in-draw/12218 "2019-06-22T10:35:07Z")

</div>

Hello! I’m new to processing and I’m having some background issues. I’m working on a data visualization of word frequency in a text, shown through a bar graph. For the example code I replaced my text with a sequence of…

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

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