# Coding Questions

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

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

**Page:** 16

---

## [Saving Sketch to PDF Issues](https://discourse.processing.org/t/saving-sketch-to-pdf-issues/40909)

<div class="topic-metadata">

**Author:** [@butterfield8](https://discourse.processing.org/u/butterfield8)\
**Replies:** 0\
**Last updated:** [February 12, 2023, 11:55pm UTC](https://discourse.processing.org/t/saving-sketch-to-pdf-issues/40909 "2023-02-12T23:55:41Z")

</div>

Hello- I am trying to save my sketch to a pdf. When I follow the documentation exactly with a simple geometry, it works fine. However, I have a function that grabs a random shape and puts it on the screen in a loop. Whe…

---

## [Access other objects in an object array](https://discourse.processing.org/t/access-other-objects-in-an-object-array/40716)

<div class="topic-metadata">

**Author:** [@geggslegs](https://discourse.processing.org/u/geggslegs)\
**Replies:** 4\
**Last updated:** [February 9, 2023, 10:48pm UTC](https://discourse.processing.org/t/access-other-objects-in-an-object-array/40716 "2023-02-09T22:48:01Z")

</div>

I’m trying to write a 2d ball pit simulation using verlet integration. But I’m having trouble accessing the other balls while looping through them. In the section commented “//collide the balls” I’m trying to access th…

---

## [A more efficient room flooding algorithm](https://discourse.processing.org/t/a-more-efficient-room-flooding-algorithm/40872)

<div class="topic-metadata">

**Author:** [@Tsskyx](https://discourse.processing.org/u/Tsskyx)\
**Replies:** 7\
**Last updated:** [February 9, 2023, 1:14am UTC](https://discourse.processing.org/t/a-more-efficient-room-flooding-algorithm/40872 "2023-02-09T01:14:35Z")

</div>

I am attempting to program the visualizations from this video. Essentially, it is a problem of propagating a signal through a graph. In this case, the graph is the canvas, the vertices are the pixels, the links exist bet…

---

## [Lights and colours in 3D?](https://discourse.processing.org/t/lights-and-colours-in-3d/40862)

<div class="topic-metadata">

**Author:** [@Raul](https://discourse.processing.org/u/Raul)\
**Replies:** 3\
**Last updated:** [February 8, 2023, 5:27am UTC](https://discourse.processing.org/t/lights-and-colours-in-3d/40862 "2023-02-08T05:27:26Z")

</div>

Hi! This shouldn’t be complicated, but I can’t figure out how to solve it. I though it would be related to lights in 3D, but I don’t find the solution. When I draw a white line in a 3D space this line - sometimes, it d…

---

## [Help with making a counter](https://discourse.processing.org/t/help-with-making-a-counter/40859)

<div class="topic-metadata">

**Author:** [@andprocessing](https://discourse.processing.org/u/andprocessing)\
**Replies:** 3\
**Last updated:** [February 7, 2023, 6:57pm UTC](https://discourse.processing.org/t/help-with-making-a-counter/40859 "2023-02-07T18:57:43Z")

</div>

Hi! I’m making a game where you have to find wolves in a pack of sheep. There are 5 wolves made with an array, and as the code is now, you advance to the next page when you click on one wolf. However, I want it to advanc…

---

## [How to increase the number of balls?](https://discourse.processing.org/t/how-to-increase-the-number-of-balls/40856)

<div class="topic-metadata">

**Author:** [@Vadimkuzmin](https://discourse.processing.org/u/Vadimkuzmin)\
**Replies:** 4\
**Last updated:** [February 7, 2023, 6:45pm UTC](https://discourse.processing.org/t/how-to-increase-the-number-of-balls/40856 "2023-02-07T18:45:33Z")

</div>

Good afternoon, there was still a problem to add at least 1 ball or many balls up to 99 and I don’t understand how to achieve this! example chart: import peasy.\*; PeasyCam camera; PImage img; boolean mpa, click; c…

---

## [Addition to video games code](https://discourse.processing.org/t/addition-to-video-games-code/40819)

<div class="topic-metadata">

**Author:** [@epicrafter](https://discourse.processing.org/u/epicrafter)\
**Replies:** 3\
**Last updated:** [February 7, 2023, 2:35pm UTC](https://discourse.processing.org/t/addition-to-video-games-code/40819 "2023-02-07T14:35:26Z")

</div>

Hello again. I am trying to make a code that I can sent to Nintendo Switches for more in-game fun. Here is the code so far: // Useful stuff for the code: STROKES: (160,35,0) for bronze, (150,150,150) for silver, // (16…

---

## [How can I prevent the image background from being rotated?](https://discourse.processing.org/t/how-can-i-prevent-the-image-background-from-being-rotated/40855)

<div class="topic-metadata">

**Author:** [@Vadimkuzmin](https://discourse.processing.org/u/Vadimkuzmin)\
**Replies:** 1\
**Last updated:** [February 7, 2023, 10:17am UTC](https://discourse.processing.org/t/how-can-i-prevent-the-image-background-from-being-rotated/40855 "2023-02-07T10:17:56Z")

</div>

Good afternoon, I use lines with balls to build curves on images. How can I prevent image background from rotating and prevent scaling! import peasy.\*; PeasyCam camera; PImage img; boolean mpa, click; color mouseC,p…

---

## [keyReleased()+ saveFrame() functions not doing anything](https://discourse.processing.org/t/keyreleased-saveframe-functions-not-doing-anything/40832)

<div class="topic-metadata">

**Author:** [@liss](https://discourse.processing.org/u/liss)\
**Replies:** 4\
**Last updated:** [February 6, 2023, 1:15am UTC](https://discourse.processing.org/t/keyreleased-saveframe-functions-not-doing-anything/40832 "2023-02-06T01:15:53Z")

</div>

Hi all, I’m an extreme novice coder taking a generative art course. I am trying to save the image I created with a series of for loops and random functions (I included one in the script below) but it is not saving the i…

---

## [PGraphics and Image problem](https://discourse.processing.org/t/pgraphics-and-image-problem/38464)

<div class="topic-metadata">

**Author:** [@eltrem](https://discourse.processing.org/u/eltrem)\
**Replies:** 1\
**Last updated:** [February 5, 2023, 6:48pm UTC](https://discourse.processing.org/t/pgraphics-and-image-problem/38464 "2023-02-05T18:48:35Z")

</div>

Hi everyone! I’m struggling with a problem which i cant seem to solve. I’m using PGraphics to sequentially save “layers” of my drawing as pngs with alpha channel. Once i’ve drawn my elements and saved each of them as …

---

## [Strange mask behaviour - troubleshooting ideas?](https://discourse.processing.org/t/strange-mask-behaviour-troubleshooting-ideas/40821)

<div class="topic-metadata">

**Author:** [@MuddyGardener](https://discourse.processing.org/u/MuddyGardener)\
**Replies:** 1\
**Last updated:** [February 3, 2023, 5:42pm UTC](https://discourse.processing.org/t/strange-mask-behaviour-troubleshooting-ideas/40821 "2023-02-03T17:42:50Z")

</div>

I am experimenting with a series of little test cases for image compositing, and am puzzled by what I’m seeing as the behaviour of pimage.mask(). PImage LayerA, LayerM; int Col2 = width/2; int Row2 = height/2; size(600…

---

## [How to make a moving background in Processing](https://discourse.processing.org/t/how-to-make-a-moving-background-in-processing/39111)

<div class="topic-metadata">

**Author:** [@epicrafter](https://discourse.processing.org/u/epicrafter)\
**Replies:** 7\
**Last updated:** [February 3, 2023, 3:19pm UTC](https://discourse.processing.org/t/how-to-make-a-moving-background-in-processing/39111 "2023-02-03T15:19:59Z")

</div>

Hello, I am having trouble making a moving background. Here is my code: int frame; void setup() { size (400,400); fill(204,102,0); frameRate (5); frame = 1; stroke (255,125,0); } void draw() { switch (frame)…

---

## [Is there a way of warping images - like Adobe's Puppet tool](https://discourse.processing.org/t/is-there-a-way-of-warping-images-like-adobes-puppet-tool/1510)

<div class="topic-metadata">

**Author:** [@stib](https://discourse.processing.org/u/stib)\
**Replies:** 9\
**Last updated:** [February 3, 2023, 2:58pm UTC](https://discourse.processing.org/t/is-there-a-way-of-warping-images-like-adobes-puppet-tool/1510 "2023-02-03T14:58:38Z")

</div>

I have an image that I want to be able to animate using a method similar to the Puppet Tool in After Effects, where points affect a mesh which has an image mapped on it. If I want to do this am I going to have to reve…

---

## [Understanding the function of CheckAlpha boolean PGraphics argument](https://discourse.processing.org/t/understanding-the-function-of-checkalpha-boolean-pgraphics-argument/40777)

<div class="topic-metadata">

**Author:** [@MuddyGardener](https://discourse.processing.org/u/MuddyGardener)\
**Replies:** 3\
**Last updated:** [February 1, 2023, 10:33am UTC](https://discourse.processing.org/t/understanding-the-function-of-checkalpha-boolean-pgraphics-argument/40777 "2023-02-01T10:33:09Z")

</div>

I am trying to figure out what the CheckAlpha argument to Pgraphics does - and how and why - and have chased my confusion down to line 281 of LINK UPDATED the core docs if ((pixels\[i\] & 0xff000000) != 0xff000000) I…

---

## [Error in code Processing](https://discourse.processing.org/t/error-in-code-processing/40742)

<div class="topic-metadata">

**Author:** [@OverLord](https://discourse.processing.org/u/OverLord)\
**Replies:** 1\
**Last updated:** [January 30, 2023, 11:34am UTC](https://discourse.processing.org/t/error-in-code-processing/40742 "2023-01-30T11:34:52Z")

</div>

The error is related to char but I can’t figure out what the problem is public final class Lexer{ private static final String OPERATORS\_CHARS = “±\*/”; private static final TokenType OPERATOR\_TOKENS ={ TokenType.PLUS,…

---

## [Seemingly Simple 3D Animation Running Very Slowly](https://discourse.processing.org/t/seemingly-simple-3d-animation-running-very-slowly/40731)

<div class="topic-metadata">

**Author:** [@monty86](https://discourse.processing.org/u/monty86)\
**Replies:** 3\
**Last updated:** [January 28, 2023, 5:10pm UTC](https://discourse.processing.org/t/seemingly-simple-3d-animation-running-very-slowly/40731 "2023-01-28T17:10:12Z")

</div>

I am fairly new to Processing and am trying to draw 3D shapes and do what seems to be a fairly simple animation. However, the performance is very poor (the animation speed is not uniform - slows way down and speeds up) a…

---

## [Scale Text to Button](https://discourse.processing.org/t/scale-text-to-button/40724)

<div class="topic-metadata">

**Author:** [@turke1034](https://discourse.processing.org/u/turke1034)\
**Replies:** 2\
**Last updated:** [January 27, 2023, 4:54pm UTC](https://discourse.processing.org/t/scale-text-to-button/40724 "2023-01-27T16:54:35Z")

</div>

Hi, I want to create text that dynamically scales to a few pixels smaller than its respective button/boundaries size and also to the size of the screen. It is very easy to let it scale dynamically to the screen; however,…

---

## [filter(GRAY) makes everything gray](https://discourse.processing.org/t/filter-gray-makes-everything-gray/40725)

<div class="topic-metadata">

**Author:** [@turke1034](https://discourse.processing.org/u/turke1034)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 7:07am UTC](https://discourse.processing.org/t/filter-gray-makes-everything-gray/40725 "2023-01-27T07:07:54Z")

</div>

In my game I am trying to make a button grayscale (temporarily) but not anything else. But it seems that there is no way to disable a filter after it is applied? pushStyle(); button.draw(); if (!button.pressable) filter…

---

## [How do I load specific parts of an image, like if I was using a sprite sheet? I was told that I could use 'get();' in order to grab a part of the image, but I don't know how to do that. Where do I include the code for this? (Sprite she](https://discourse.processing.org/t/how-do-i-load-specific-parts-of-an-image-like-if-i-was-using-a-sprite-sheet-i-was-told-that-i-could-use-get-in-order-to-grab-a-part-of-the-image-but-i-dont-know-how-to-do-that-where-do-i-include-the-code-for-this-sprite-she/40714)

<div class="topic-metadata">

**Author:** [@FelixBrooks](https://discourse.processing.org/u/FelixBrooks)\
**Replies:** 7\
**Last updated:** [January 26, 2023, 8:05pm UTC](https://discourse.processing.org/t/how-do-i-load-specific-parts-of-an-image-like-if-i-was-using-a-sprite-sheet-i-was-told-that-i-could-use-get-in-order-to-grab-a-part-of-the-image-but-i-dont-know-how-to-do-that-where-do-i-include-the-code-for-this-sprite-she/40714 "2023-01-26T20:05:41Z")

</div>

\<PImage Walking; color c - color(0); void setup(); background(c); noStroke(); fill(c); Walking = loadImage('Walking-Animation.png"); void draw(); display(); image(Walking, pos.x, pos.y); // This is where I’m st…

---

## [How to make a bullets aim towards the mouse, but not continue to follow it?](https://discourse.processing.org/t/how-to-make-a-bullets-aim-towards-the-mouse-but-not-continue-to-follow-it/40699)

<div class="topic-metadata">

**Author:** [@UltimateDoug](https://discourse.processing.org/u/UltimateDoug)\
**Replies:** 3\
**Last updated:** [January 26, 2023, 8:37pm UTC](https://discourse.processing.org/t/how-to-make-a-bullets-aim-towards-the-mouse-but-not-continue-to-follow-it/40699 "2023-01-26T20:37:44Z")

</div>

How can I make my bullets follow the mouse position momentarily, but then forget its position so it wont continue to follow the mouse Bullet Class class Bullet { PVector pos; PVector spd; float damage; PVector …

---

## [Need some help with glsl shaders](https://discourse.processing.org/t/need-some-help-with-glsl-shaders/40701)

<div class="topic-metadata">

**Author:** [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Replies:** 17\
**Last updated:** [January 26, 2023, 4:06am UTC](https://discourse.processing.org/t/need-some-help-with-glsl-shaders/40701 "2023-01-26T04:06:18Z")

</div>

Hi, im completely new to glsl and looking for a decent resource to start coding them for processing, just looking for the bare basics of drawing 2d pixels to the screen at this point, cant wrap my head around them, watch…

---

## [How can i resolve Runtime Error?](https://discourse.processing.org/t/how-can-i-resolve-runtime-error/40710)

<div class="topic-metadata">

**Author:** [@happycode](https://discourse.processing.org/u/happycode)\
**Replies:** 1\
**Last updated:** [January 25, 2023, 9:41pm UTC](https://discourse.processing.org/t/how-can-i-resolve-runtime-error/40710 "2023-01-25T21:41:55Z")

</div>

I have written an Java Processing application. If I try to start it, I get the following error: ""processing.core.PGraphics.createShape(int, float\[\])" because "this.g" is null". My Application has a View, Controller an…

---

## [Screen limits with random points](https://discourse.processing.org/t/screen-limits-with-random-points/40711)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 1\
**Last updated:** [January 25, 2023, 9:05pm UTC](https://discourse.processing.org/t/screen-limits-with-random-points/40711 "2023-01-25T21:05:33Z")

</div>

Hi there! I have this amazing Code as a polygon generator. It is really useful for me in order yo create random shapes. Now I want to draw polygons inside the screen, because ofently they appear out of It, how could I do…

---

## [Cursors in OpenGL Mode?](https://discourse.processing.org/t/cursors-in-opengl-mode/40680)

<div class="topic-metadata">

**Author:** [@Aryszin](https://discourse.processing.org/u/Aryszin)\
**Replies:** 4\
**Last updated:** [January 24, 2023, 8:03am UTC](https://discourse.processing.org/t/cursors-in-opengl-mode/40680 "2023-01-24T08:03:53Z")

</div>

Is it possible to get the standard cursors in OpenGL Drawing mode? i also mean when you resize a window, bc OpenGL doesnt show them!

---

## [Help I need to edit a game code (clouds)](https://discourse.processing.org/t/help-i-need-to-edit-a-game-code-clouds/40671)

<div class="topic-metadata">

**Author:** [@val](https://discourse.processing.org/u/val)\
**Replies:** 5\
**Last updated:** [January 24, 2023, 5:56am UTC](https://discourse.processing.org/t/help-i-need-to-edit-a-game-code-clouds/40671 "2023-01-24T05:56:08Z")

</div>

Hello, I’m really puzzled on what to do with this quiz. I was given a gaming code and need to personalize it. I tried adding clouds into the game code but I want to find a way to simplify the code and make it look clea…

---

## [Help with simple game (moving fish)](https://discourse.processing.org/t/help-with-simple-game-moving-fish/40679)

<div class="topic-metadata">

**Author:** [@sara](https://discourse.processing.org/u/sara)\
**Replies:** 9\
**Last updated:** [January 23, 2023, 9:38pm UTC](https://discourse.processing.org/t/help-with-simple-game-moving-fish/40679 "2023-01-23T21:38:12Z")

</div>

Can somebody help me? I created a simple game where you have to catch fish. at the moment these fish just move from the left side to the right side of the screen. What I need to do is make them change the direction in …

---

## [Use GPU and not CPU for processing](https://discourse.processing.org/t/use-gpu-and-not-cpu-for-processing/40686)

<div class="topic-metadata">

**Author:** [@BBGiraffe](https://discourse.processing.org/u/BBGiraffe)\
**Replies:** 2\
**Last updated:** [January 23, 2023, 5:45pm UTC](https://discourse.processing.org/t/use-gpu-and-not-cpu-for-processing/40686 "2023-01-23T17:45:46Z")

</div>

I have a processing script that processes and plots millions of dots to picture, I’m creating many images at once and the script seems to drive the CPU to 100%. I have a separate, modern GPU that is sitting mostly idle. …

---

## [Source code compatibility problems with 3.5.4](https://discourse.processing.org/t/source-code-compatibility-problems-with-3-5-4/40674)

<div class="topic-metadata">

**Author:** [@tomjennings](https://discourse.processing.org/u/tomjennings)\
**Replies:** 6\
**Last updated:** [January 22, 2023, 8:40pm UTC](https://discourse.processing.org/t/source-code-compatibility-problems-with-3-5-4/40674 "2023-01-22T20:40:09Z")

</div>

I had been running 3.5.4, thought I’d update to 4, ran into this (first) compatibility issue. I can find no overall 4 vs 3 compatibility discussion, forum, or FAQ, there must be one? This code fragment: import java.uti…

---

## [Pd4P3 How to start a code that do this kind of example of generative fractals (as in the link) in Processing](https://discourse.processing.org/t/pd4p3-how-to-start-a-code-that-do-this-kind-of-example-of-generative-fractals-as-in-the-link-in-processing/40450)

<div class="topic-metadata">

**Author:** [@vrtx](https://discourse.processing.org/u/vrtx)\
**Replies:** 0\
**Last updated:** [January 5, 2023, 12:46am UTC](https://discourse.processing.org/t/pd4p3-how-to-start-a-code-that-do-this-kind-of-example-of-generative-fractals-as-in-the-link-in-processing/40450 "2023-01-05T00:46:27Z")

</div>

I looking to start mixup some art-patterns and this as this link https://vimeo.com/user5020648, is the kind i am looking for, in this moment. This paterns like https://youtu.be/CLddxGIlVPU also is lovely… I saw this " …

---

## [Reference subclass method in superclass method](https://discourse.processing.org/t/reference-subclass-method-in-superclass-method/40662)

<div class="topic-metadata">

**Author:** [@nanto2016](https://discourse.processing.org/u/nanto2016)\
**Replies:** 1\
**Last updated:** [January 20, 2023, 6:00pm UTC](https://discourse.processing.org/t/reference-subclass-method-in-superclass-method/40662 "2023-01-20T18:00:51Z")

</div>

I have a Saw class that extends the Enemy class. class Enemy { int hp, atk, n; float spd; PVector pos = new PVector(random(width), random(height)); Enemy(int hp\_, float spd\_, int atk\_, int n\_) { hp = hp\_; …

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

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