# Coding Questions

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

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

**Page:** 97

---

## [Grab Pixels Around Edges of an Irregular Image Shape](https://discourse.processing.org/t/grab-pixels-around-edges-of-an-irregular-image-shape/20020)

<div class="topic-metadata">

**Author:** [@mnoble](https://discourse.processing.org/u/mnoble)\
**Replies:** 4\
**Last updated:** [May 3, 2020, 6:22pm UTC](https://discourse.processing.org/t/grab-pixels-around-edges-of-an-irregular-image-shape/20020 "2020-05-03T18:22:05Z")

</div>

Hello Forum, I am wondering if there is a simple way to grab the pixels around the edges of an irregular image that is accurate? I have been having a blast with the simplicity of color detection for moving collisions. I…

---

## [Drawing shapes in between loadPixels() and updatePixels()](https://discourse.processing.org/t/drawing-shapes-in-between-loadpixels-and-updatepixels/19991)

<div class="topic-metadata">

**Author:** [@Gabe](https://discourse.processing.org/u/Gabe)\
**Replies:** 3\
**Last updated:** [May 3, 2020, 5:42pm UTC](https://discourse.processing.org/t/drawing-shapes-in-between-loadpixels-and-updatepixels/19991 "2020-05-03T17:42:11Z")

</div>

I notice that I can’t draw primitive shapes in between calls to loadPixels() and updatePixels(). Consider the following sketch: void setup() { size(200, 100); } void draw() { fill(0); ellipseMode(CENTER); ellip…

---

## [Boids - Can I improve my method / efficiency?](https://discourse.processing.org/t/boids-can-i-improve-my-method-efficiency/20256)

<div class="topic-metadata">

**Author:** [@ketchupmustard](https://discourse.processing.org/u/ketchupmustard)\
**Replies:** 9\
**Last updated:** [May 3, 2020, 1:34pm UTC](https://discourse.processing.org/t/boids-can-i-improve-my-method-efficiency/20256 "2020-05-03T13:34:12Z")

</div>

Hi all, first post! So this is my first big stab at boids. It’s still kinda wonky - I plan to implement more features and corrections. I’m more looking for any general tips to increase efficiency (I’m not sure if it’s j…

---

## [Can you help me with an issue](https://discourse.processing.org/t/can-you-help-me-with-an-issue/20430)

<div class="topic-metadata">

**Author:** [@Arsenii](https://discourse.processing.org/u/Arsenii)\
**Replies:** 1\
**Last updated:** [May 3, 2020, 1:24pm UTC](https://discourse.processing.org/t/can-you-help-me-with-an-issue/20430 "2020-05-03T13:24:27Z")

</div>

I can’t understand why triangle does not rotating. spaceShip ship; void setup() { size(640, 360); ship = new spaceShip(); } void draw() { background(0); ship.render(); //ship.turn(0.1); } void KeyPressed(…

---

## [Zoom/Pan constraints](https://discourse.processing.org/t/zoom-pan-constraints/20420)

<div class="topic-metadata">

**Author:** [@royschn](https://discourse.processing.org/u/royschn)\
**Replies:** 10\
**Last updated:** [May 3, 2020, 12:19pm UTC](https://discourse.processing.org/t/zoom-pan-constraints/20420 "2020-05-03T12:19:25Z")

</div>

hi all, I have a simple code that allows drawing in the Processing canvas. Scrolling the mouse allows you to zoom in and out while press and drag the right button moves the drawing accordingly (PAN). What I’m trying to…

---

## [Array reset help](https://discourse.processing.org/t/array-reset-help/20423)

<div class="topic-metadata">

**Author:** [@Dylan](https://discourse.processing.org/u/Dylan)\
**Replies:** 3\
**Last updated:** [May 3, 2020, 11:15am UTC](https://discourse.processing.org/t/array-reset-help/20423 "2020-05-03T11:15:56Z")

</div>

I’m trying to have the array reset all of the numbers to random numbers when I press the ‘r’ key but it’s not working int many=20; int\[\] array = new int\[many\]; void setup() { size(640, 480); } void draw() { scene()…

---

## [Random Image Generation + Random Rotation](https://discourse.processing.org/t/random-image-generation-random-rotation/20372)

<div class="topic-metadata">

**Author:** [@GDlauren20](https://discourse.processing.org/u/GDlauren20)\
**Replies:** 4\
**Last updated:** [May 2, 2020, 7:14pm UTC](https://discourse.processing.org/t/random-image-generation-random-rotation/20372 "2020-05-02T19:14:10Z")

</div>

Hi, I have generated a bit of code whereby a random image, selected from my array, appears on screen where the user clicked. It currently is working but need the images that appear to randomly rotate (around the centre p…

---

## [Processing net question](https://discourse.processing.org/t/processing-net-question/20377)

<div class="topic-metadata">

**Author:** [@emanresU](https://discourse.processing.org/u/emanresU)\
**Replies:** 1\
**Last updated:** [May 2, 2020, 4:53pm UTC](https://discourse.processing.org/t/processing-net-question/20377 "2020-05-02T16:53:50Z")

</div>

how i can conect to the server (library processing.net.\*) in the global net but no in the local net

---

## [A better way to write this IF statement](https://discourse.processing.org/t/a-better-way-to-write-this-if-statement/20322)

<div class="topic-metadata">

**Author:** [@normalnatural](https://discourse.processing.org/u/normalnatural)\
**Replies:** 5\
**Last updated:** [May 2, 2020, 4:35pm UTC](https://discourse.processing.org/t/a-better-way-to-write-this-if-statement/20322 "2020-05-02T16:35:57Z")

</div>

Hi there, I’m very new to processing and I was wondering if there’s a better way to write this IF statement. What I’m doing is creating a drawing tool and want to confine the line to a space in the window. This statemen…

---

## [Slowing down mouse](https://discourse.processing.org/t/slowing-down-mouse/20357)

<div class="topic-metadata">

**Author:** [@14mmss](https://discourse.processing.org/u/14mmss)\
**Replies:** 2\
**Last updated:** [May 2, 2020, 3:34pm UTC](https://discourse.processing.org/t/slowing-down-mouse/20357 "2020-05-02T15:34:41Z")

</div>

Hello, I wanted to make an ellipse that would follow the mouse but slowed down. Can anyone tell me why my code doesn’t work? float x, y; float speed = 7; void setup() { size(1000,1000); smooth(); frameRate(30); …

---

## [How to move the mouse by code](https://discourse.processing.org/t/how-to-move-the-mouse-by-code/20376)

<div class="topic-metadata">

**Author:** [@emanresU](https://discourse.processing.org/u/emanresU)\
**Replies:** 1\
**Last updated:** [May 2, 2020, 6:05am UTC](https://discourse.processing.org/t/how-to-move-the-mouse-by-code/20376 "2020-05-02T06:05:51Z")

</div>

how i can move the mouse by code in to the center of the display (window) like in 3d games where it uses for rotate the camera (i know inglish very well)

---

## [Question about a bug in my code](https://discourse.processing.org/t/question-about-a-bug-in-my-code/20164)

<div class="topic-metadata">

**Author:** [@Adi](https://discourse.processing.org/u/Adi)\
**Replies:** 23\
**Last updated:** [May 1, 2020, 9:19pm UTC](https://discourse.processing.org/t/question-about-a-bug-in-my-code/20164 "2020-05-01T21:19:19Z")

</div>

Hi all, I have created this code which aimes on a square which is taken from the top-left corner to the x and y values of the mouse when the mouse is pressed. Those 2 values are rectX and rectY. Two lines from the x-axi…

---

## [I want to show text in screen independently while using 3D camera](https://discourse.processing.org/t/i-want-to-show-text-in-screen-independently-while-using-3d-camera/20361)

<div class="topic-metadata">

**Author:** [@SilverPrevail](https://discourse.processing.org/u/SilverPrevail)\
**Replies:** 3\
**Last updated:** [May 1, 2020, 6:26pm UTC](https://discourse.processing.org/t/i-want-to-show-text-in-screen-independently-while-using-3d-camera/20361 "2020-05-01T18:26:33Z")

</div>

import java.awt.AWTException; import java.awt.Robot; public class Player{ public float x; public float y; public float z; public float vz; public float theta; public float phi; public float speed; } boole…

---

## [Giving elements HSB rainbow colors in a for loop](https://discourse.processing.org/t/giving-elements-hsb-rainbow-colors-in-a-for-loop/20316)

<div class="topic-metadata">

**Author:** [@Elfriede](https://discourse.processing.org/u/Elfriede)\
**Replies:** 5\
**Last updated:** [May 1, 2020, 6:24pm UTC](https://discourse.processing.org/t/giving-elements-hsb-rainbow-colors-in-a-for-loop/20316 "2020-05-01T18:24:22Z")

</div>

Hey eyeryone. So this is my first post. I’ve only started with processing. We got the task to make a grid of 2D Primitives which can be altered through changing the size() or number of elements. I figured that part ou…

---

## [Problems with gravity simulation](https://discourse.processing.org/t/problems-with-gravity-simulation/20349)

<div class="topic-metadata">

**Author:** [@Kport1](https://discourse.processing.org/u/Kport1)\
**Replies:** 4\
**Last updated:** [May 1, 2020, 5:53pm UTC](https://discourse.processing.org/t/problems-with-gravity-simulation/20349 "2020-05-01T17:53:35Z")

</div>

ArrayList\<Body\> objects = new ArrayList\<Body\>(100); ArrayList\<Body\> destroy = new ArrayList\<Body\>(); float m1 = 0.5; float m2 = 1; float G = 0.00002; int maxDist = 1; float scale = 1; PVector mouse = new PVector(0, 0…

---

## [Can't normalize fonts according to x-height](https://discourse.processing.org/t/cant-normalize-fonts-according-to-x-height/20324)

<div class="topic-metadata">

**Author:** [@dehyde](https://discourse.processing.org/u/dehyde)\
**Replies:** 3\
**Last updated:** [May 1, 2020, 6:34am UTC](https://discourse.processing.org/t/cant-normalize-fonts-according-to-x-height/20324 "2020-05-01T06:34:23Z")

</div>

Hi, I’m trying to create a normalized version of the same letter in multiple fonts. It doesn’t work as you can see in the image, the height is different for each font (same letter) I’m looping through all the fonts …

---

## [Move two shapes at a time with the keyboard](https://discourse.processing.org/t/move-two-shapes-at-a-time-with-the-keyboard/20203)

<div class="topic-metadata">

**Author:** [@Ear1yT](https://discourse.processing.org/u/Ear1yT)\
**Replies:** 6\
**Last updated:** [May 1, 2020, 1:22am UTC](https://discourse.processing.org/t/move-two-shapes-at-a-time-with-the-keyboard/20203 "2020-05-01T01:22:51Z")

</div>

Hi I’m trying to write a little Pong Game with a multi and a singleplayer. Almost everything works, I just can’t get the control of the two paddles in multiplayer right. I honestly don’t know what’s the problem, but as …

---

## [More an issue rather a coding question](https://discourse.processing.org/t/more-an-issue-rather-a-coding-question/19925)

<div class="topic-metadata">

**Author:** [@f42ter](https://discourse.processing.org/u/f42ter)\
**Replies:** 3\
**Last updated:** [May 1, 2020, 1:05am UTC](https://discourse.processing.org/t/more-an-issue-rather-a-coding-question/19925 "2020-05-01T01:05:27Z")

</div>

I start to play with an implementation of brainf\*ck. Works well so far, until it come to more complex bf code, like the mandelbrot.bf. Issue is, that while printig the result using the print statement sometime some prin…

---

## [Can you distinguish between the first time pressing a space bar and the second?](https://discourse.processing.org/t/can-you-distinguish-between-the-first-time-pressing-a-space-bar-and-the-second/19846)

<div class="topic-metadata">

**Author:** [@14mmss](https://discourse.processing.org/u/14mmss)\
**Replies:** 1\
**Last updated:** [April 16, 2020, 8:20pm UTC](https://discourse.processing.org/t/can-you-distinguish-between-the-first-time-pressing-a-space-bar-and-the-second/19846 "2020-04-16T20:20:12Z")

</div>

for my code, I need to use the space bar for both actions. but as one does something and the other does another, they end up clashing, is there any way to distinguish them? my code is for a reaction time experiment, and…

---

## [Can somebody help me with this question?](https://discourse.processing.org/t/can-somebody-help-me-with-this-question/20323)

<div class="topic-metadata">

**Author:** [@oliver\_humsafah](https://discourse.processing.org/u/oliver_humsafah)\
**Replies:** 1\
**Last updated:** [April 30, 2020, 8:08pm UTC](https://discourse.processing.org/t/can-somebody-help-me-with-this-question/20323 "2020-04-30T20:08:12Z")

</div>

Write a public function called HW8C which accepts an array of int(s) ( integers) anreturns an ArrayList containing those numbers in an appropriate form. Please use aloop to do the copy.

---

## [Custom class that extends PGraphics class not working](https://discourse.processing.org/t/custom-class-that-extends-pgraphics-class-not-working/20199)

<div class="topic-metadata">

**Author:** [@Ayfri](https://discourse.processing.org/u/Ayfri)\
**Replies:** 5\
**Last updated:** [April 30, 2020, 7:06pm UTC](https://discourse.processing.org/t/custom-class-that-extends-pgraphics-class-not-working/20199 "2020-04-30T19:06:09Z")

</div>

I have this custom Button class that extends PGraphics but I can’t figure it out how to make it working, the draw function just do nothing, I inspected the pixels and before sketch(this, x, y);, all pixels are equals to 0…

---

## [Contours with Bezier Vertex](https://discourse.processing.org/t/contours-with-bezier-vertex/20306)

<div class="topic-metadata">

**Author:** [@rebeccajkaye](https://discourse.processing.org/u/rebeccajkaye)\
**Replies:** 4\
**Last updated:** [April 30, 2020, 5:14pm UTC](https://discourse.processing.org/t/contours-with-bezier-vertex/20306 "2020-04-30T17:14:42Z")

</div>

Hello I was hoping somebody may be able to help me figure out what I’ve done wrong with my code. I’m just trying to create a square with a circle cut out and it’s not seeming to do what I want. This is my code - any he…

---

## [Fresnel effect in PShader not working right?](https://discourse.processing.org/t/fresnel-effect-in-pshader-not-working-right/20283)

<div class="topic-metadata">

**Author:** [@Bordin](https://discourse.processing.org/u/Bordin)\
**Replies:** 1\
**Last updated:** [April 30, 2020, 4:09pm UTC](https://discourse.processing.org/t/fresnel-effect-in-pshader-not-working-right/20283 "2020-04-30T16:09:54Z")

</div>

I’m currently trying to follow the famous Nvidia guide to water simulation, and I’m making some okay progress. My waves are oddly flat but that’s not really the issue. I got to the point where I wanted to implemented a r…

---

## [Advancing loop one frame at a time then save frame as a PDF -- doesn’t always save frame seen on screen](https://discourse.processing.org/t/advancing-loop-one-frame-at-a-time-then-save-frame-as-a-pdf-doesn-t-always-save-frame-seen-on-screen/20287)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 2\
**Last updated:** [April 30, 2020, 3:52pm UTC](https://discourse.processing.org/t/advancing-loop-one-frame-at-a-time-then-save-frame-as-a-pdf-doesn-t-always-save-frame-seen-on-screen/20287 "2020-04-30T15:52:16Z")

</div>

This is a piece of a larger sketch I have reduced down to basic elements for the question. It is currently set up to redraw one frame at a time when keyPressed. And with mousePressed to record a PDF of the frame shown …

---

## [Making an object appear multiple times when required](https://discourse.processing.org/t/making-an-object-appear-multiple-times-when-required/20236)

<div class="topic-metadata">

**Author:** [@captainmajere](https://discourse.processing.org/u/captainmajere)\
**Replies:** 1\
**Last updated:** [April 30, 2020, 11:41am UTC](https://discourse.processing.org/t/making-an-object-appear-multiple-times-when-required/20236 "2020-04-30T11:41:58Z")

</div>

I am trying to make a game about consuming balls and I have yet to find a solution for these two problems. 1- Making collision a one time thing without using a flag 2-Making my redorbs spawn exponantially after consumi…

---

## [Bubbles transform to black rectangles](https://discourse.processing.org/t/bubbles-transform-to-black-rectangles/20258)

<div class="topic-metadata">

**Author:** [@gurki](https://discourse.processing.org/u/gurki)\
**Replies:** 6\
**Last updated:** [April 30, 2020, 11:18am UTC](https://discourse.processing.org/t/bubbles-transform-to-black-rectangles/20258 "2020-04-30T11:18:04Z")

</div>

Hello Guys, I need help from an task where I am not quite sure where I am wrong. The task is in German but I will translate it via Deppl.com to english: Write the class Blubb with the four properties x, y, d (all floa…

---

## [Checking if a file exists - strange runtime error](https://discourse.processing.org/t/checking-if-a-file-exists-strange-runtime-error/20276)

<div class="topic-metadata">

**Author:** [@PhilHaw](https://discourse.processing.org/u/PhilHaw)\
**Replies:** 7\
**Last updated:** [April 30, 2020, 11:14am UTC](https://discourse.processing.org/t/checking-if-a-file-exists-strange-runtime-error/20276 "2020-04-30T11:14:00Z")

</div>

I’m trying to write a routine that will load from a user’s file (required filename is, say “My patches.txt”) in the data folder but that will default to another file if the user’s file does not exist. I found the ‘file e…

---

## [Storing Files in a Folder](https://discourse.processing.org/t/storing-files-in-a-folder/20265)

<div class="topic-metadata">

**Author:** [@Jack](https://discourse.processing.org/u/Jack)\
**Replies:** 3\
**Last updated:** [April 29, 2020, 1:56pm UTC](https://discourse.processing.org/t/storing-files-in-a-folder/20265 "2020-04-29T13:56:34Z")

</div>

Hello, I am working on a project currently where I have about 80 images to use. I would like all of these images to be in an array. As this number of images makes the files look cluttered, I would like to be able to sto…

---

## [Using Hexidecimal colors from a table (BEGINNER)](https://discourse.processing.org/t/using-hexidecimal-colors-from-a-table-beginner/19958)

<div class="topic-metadata">

**Author:** [@BenEvans](https://discourse.processing.org/u/BenEvans)\
**Replies:** 2\
**Last updated:** [April 29, 2020, 9:32am UTC](https://discourse.processing.org/t/using-hexidecimal-colors-from-a-table-beginner/19958 "2020-04-29T09:32:07Z")

</div>

Very basic question about how to pull hexi colors from a table. I want to have a bunch of six-character, regular ol’ hexidecimal colors in a column and use them to color my circles or lines or whatever. But it seems that…

---

## [Why am I getting InvocationTargetException?](https://discourse.processing.org/t/why-am-i-getting-invocationtargetexception/19917)

<div class="topic-metadata">

**Author:** [@Hypercube](https://discourse.processing.org/u/Hypercube)\
**Replies:** 1\
**Last updated:** [April 29, 2020, 5:11am UTC](https://discourse.processing.org/t/why-am-i-getting-invocationtargetexception/19917 "2020-04-29T05:11:05Z")

</div>

The code (it’s supposed to draw traffic lights: 1st a rectangle then 3 colored circles in it. The circles all start out as gray) final int windowWidth = 480; final int windowHeight = windowWidth; int timer; //final fl…

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

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