# Coding Questions

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

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

**Page:** 98

---

## [Help on reset draw()](https://discourse.processing.org/t/help-on-reset-draw/20110)

<div class="topic-metadata">

**Author:** [@random\_programmer](https://discourse.processing.org/u/random_programmer)\
**Replies:** 7\
**Last updated:** [April 28, 2020, 11:11pm UTC](https://discourse.processing.org/t/help-on-reset-draw/20110 "2020-04-28T23:11:30Z")

</div>

Hello there, here is my code for a tic tac toe game. How can I reset the game by pressing the reset button? I only want to reset draw(). Is there any way to do this? int rows = 3; int cols = 3; int \[\] \[\] matrix = new …

---

## [How do you find the latitude and longitude of a image map when hovering or clicking the mouse?](https://discourse.processing.org/t/how-do-you-find-the-latitude-and-longitude-of-a-image-map-when-hovering-or-clicking-the-mouse/20063)

<div class="topic-metadata">

**Author:** [@Stage1](https://discourse.processing.org/u/Stage1)\
**Replies:** 6\
**Last updated:** [April 28, 2020, 10:03pm UTC](https://discourse.processing.org/t/how-do-you-find-the-latitude-and-longitude-of-a-image-map-when-hovering-or-clicking-the-mouse/20063 "2020-04-28T22:03:40Z")

</div>

Hi, i would like to know if there is a way to find the coordinates of an image when clicked on a specific area on the image or when hovered over with a mouse.

---

## [Image() is slow, are there any alternatives?](https://discourse.processing.org/t/image-is-slow-are-there-any-alternatives/20146)

<div class="topic-metadata">

**Author:** [@KevinWho](https://discourse.processing.org/u/KevinWho)\
**Replies:** 24\
**Last updated:** [April 28, 2020, 7:51pm UTC](https://discourse.processing.org/t/image-is-slow-are-there-any-alternatives/20146 "2020-04-28T19:51:18Z")

</div>

I am rendering about 1024 images, they have to be scaled up, I store the scaled-up version so it is a bit faster. these images are covering the whole screen, and I would like to get at least 60 fps when rendering this. I…

---

## [saveFrame() not saving the whole frame in P3D](https://discourse.processing.org/t/saveframe-not-saving-the-whole-frame-in-p3d/20244)

<div class="topic-metadata">

**Author:** [@ivaneo](https://discourse.processing.org/u/ivaneo)\
**Replies:** 2\
**Last updated:** [April 28, 2020, 6:57pm UTC](https://discourse.processing.org/t/saveframe-not-saving-the-whole-frame-in-p3d/20244 "2020-04-28T18:57:41Z")

</div>

Hello, I have a 1920x1080p P3D sketch that I want to export, however, when I use saveFrame(), it only saves what is appearing on the screen, so I get a frame that has a part of it cut off and black. I have a 1366x768p di…

---

## [How to use length of a string for collision detection](https://discourse.processing.org/t/how-to-use-length-of-a-string-for-collision-detection/20218)

<div class="topic-metadata">

**Author:** [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Replies:** 2\
**Last updated:** [April 28, 2020, 6:08pm UTC](https://discourse.processing.org/t/how-to-use-length-of-a-string-for-collision-detection/20218 "2020-04-28T18:08:42Z")

</div>

So I have this code that displays a string, and whenever the mouse hovers over it, then it changes colour. if (mouseX \> 40 && mouseX \< text.length() \* 17) fill(0); The text size is 25. However, it seems that text.l…

---

## [PShape get Children target name afterwards](https://discourse.processing.org/t/pshape-get-children-target-name-afterwards/20189)

<div class="topic-metadata">

**Author:** [@eduzal](https://discourse.processing.org/u/eduzal)\
**Replies:** 2\
**Last updated:** [April 28, 2020, 4:22pm UTC](https://discourse.processing.org/t/pshape-get-children-target-name-afterwards/20189 "2020-04-28T16:22:43Z")

</div>

Hi, i’m working on the next iteration of my corona virus data viz apllication and got stuck in a PShape issue. Is there a way to get PShape children target names? Above is the current situation of the dashboard. The i…

---

## [Pixelate Ellipse Shape](https://discourse.processing.org/t/pixelate-ellipse-shape/20148)

<div class="topic-metadata">

**Author:** [@AndJ](https://discourse.processing.org/u/AndJ)\
**Replies:** 7\
**Last updated:** [April 27, 2020, 11:49pm UTC](https://discourse.processing.org/t/pixelate-ellipse-shape/20148 "2020-04-27T23:49:03Z")

</div>

As I was working through a project, I was wondering if there was a way to make a “pixelated ellipse” in Processing (I have provided an example of what I was thinking). I don’t want to have to import an image.

---

## [Easy question about if and function](https://discourse.processing.org/t/easy-question-about-if-and-function/20205)

<div class="topic-metadata">

**Author:** [@thom](https://discourse.processing.org/u/thom)\
**Replies:** 5\
**Last updated:** [April 27, 2020, 10:57pm UTC](https://discourse.processing.org/t/easy-question-about-if-and-function/20205 "2020-04-27T22:57:08Z")

</div>

I’m trying to make a simple tic tac toe game in processing. I don’t understand why the functions don’t follow the if() statements. CODE: int counter=0; void setup(){ size(500,500); background(255); strokeWeight(15); li…

---

## [Ball should change direction after touching edge of the frame](https://discourse.processing.org/t/ball-should-change-direction-after-touching-edge-of-the-frame/20207)

<div class="topic-metadata">

**Author:** [@julia1312](https://discourse.processing.org/u/julia1312)\
**Replies:** 3\
**Last updated:** [April 27, 2020, 2:42pm UTC](https://discourse.processing.org/t/ball-should-change-direction-after-touching-edge-of-the-frame/20207 "2020-04-27T14:42:38Z")

</div>

Hi! I am completely new in the world of programming! I have started my programming lessons recently and I am stuck with my homework. What I basically have to do is a moving ball. The ball should move with velocity 20 pix…

---

## [Make a object class with random size](https://discourse.processing.org/t/make-a-object-class-with-random-size/19901)

<div class="topic-metadata">

**Author:** [@PabloTryAnimations](https://discourse.processing.org/u/PabloTryAnimations)\
**Replies:** 3\
**Last updated:** [April 27, 2020, 11:47am UTC](https://discourse.processing.org/t/make-a-object-class-with-random-size/19901 "2020-04-27T11:47:29Z")

</div>

I’m trying to make the size random in an object class Peixe (designed with BeginShape, and moving with pop Matrix ). I tried with scale, but didn’t work. Please Could you help me? void setup() { size (1000, 800); p…

---

## [Creating a font in setup but getting error in draw that no font are loaded](https://discourse.processing.org/t/creating-a-font-in-setup-but-getting-error-in-draw-that-no-font-are-loaded/20195)

<div class="topic-metadata">

**Author:** [@Ayfri](https://discourse.processing.org/u/Ayfri)\
**Replies:** 4\
**Last updated:** [April 27, 2020, 8:42am UTC](https://discourse.processing.org/t/creating-a-font-in-setup-but-getting-error-in-draw-that-no-font-are-loaded/20195 "2020-04-27T08:42:39Z")

</div>

Hi ! I’m using this code to generate a font that and use it in my setup function : public void setup() { PFont font = createFont("Arial", 32); textFont(font); } And on my draw function I just do public void d…

---

## [Rotating arcs based on probability are not all appearing in sketch](https://discourse.processing.org/t/rotating-arcs-based-on-probability-are-not-all-appearing-in-sketch/20147)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 5\
**Last updated:** [April 27, 2020, 1:44am UTC](https://discourse.processing.org/t/rotating-arcs-based-on-probability-are-not-all-appearing-in-sketch/20147 "2020-04-27T01:44:27Z")

</div>

Using probability I am trying to rotate arc object motifs in a 1D grid. I feel like I’ve tried every placement possibility of push&popMatrix (in class and main program) so that each arc rotates individually according to…

---

## [How to write files](https://discourse.processing.org/t/how-to-write-files/20155)

<div class="topic-metadata">

**Author:** [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Replies:** 5\
**Last updated:** [April 27, 2020, 12:31am UTC](https://discourse.processing.org/t/how-to-write-files/20155 "2020-04-27T00:31:21Z")

</div>

So I have this code: import java.io.FileWriter; FileWriter writeFile = new FileWriter("file.txt"); void setup() { noLoop(); } void draw() { writeFile.write("Hello World!"); writeFile.close(); } But the en…

---

## [Draw pictures by y positions](https://discourse.processing.org/t/draw-pictures-by-y-positions/19916)

<div class="topic-metadata">

**Author:** [@NoName](https://discourse.processing.org/u/NoName)\
**Replies:** 4\
**Last updated:** [April 26, 2020, 2:25pm UTC](https://discourse.processing.org/t/draw-pictures-by-y-positions/19916 "2020-04-26T14:25:57Z")

</div>

Hello. The situation needs help. I (for the game) need the characters to be drawn gradually (as if the game understands which character is closer to the camera and which is not). And at the same time, that there were …

---

## [Processing Large Image Sequences, Saving Frames](https://discourse.processing.org/t/processing-large-image-sequences-saving-frames/19938)

<div class="topic-metadata">

**Author:** [@derivativejojomemes](https://discourse.processing.org/u/derivativejojomemes)\
**Replies:** 5\
**Last updated:** [April 25, 2020, 8:27pm UTC](https://discourse.processing.org/t/processing-large-image-sequences-saving-frames/19938 "2020-04-25T20:27:49Z")

</div>

Hi! I am looking for a way to load a large number of images (PNG files extracted from a video, all inside a folder in the .pde file’s directory) in a sequence: Load the first image in the sequence (for example: “abc00…

---

## [Array out of range exeption into School project](https://discourse.processing.org/t/array-out-of-range-exeption-into-school-project/20133)

<div class="topic-metadata">

**Author:** [@Jestsect](https://discourse.processing.org/u/Jestsect)\
**Replies:** 6\
**Last updated:** [April 25, 2020, 2:37pm UTC](https://discourse.processing.org/t/array-out-of-range-exeption-into-school-project/20133 "2020-04-25T14:37:11Z")

</div>

Hello, I’m trying to make a Space invader like game for a school project, but I have a problem with collisions: I have an arry wich contain shot’s coordonates and an other which contain ennemis oordonates. Ennemies spaw…

---

## [Nested for loop not 'animating'](https://discourse.processing.org/t/nested-for-loop-not-animating/20083)

<div class="topic-metadata">

**Author:** [@timAllan](https://discourse.processing.org/u/timAllan)\
**Replies:** 8\
**Last updated:** [April 25, 2020, 6:45am UTC](https://discourse.processing.org/t/nested-for-loop-not-animating/20083 "2020-04-25T06:45:13Z")

</div>

Hi, I’m having trouble getting some nested for loops to ‘animate’… My code draws an enlarged ‘pixel grid’ by iterating through a 3D array, which contains a number of pixel ‘configurations’, each containing 3 ‘rows’ of …

---

## [Better color gradient for custom PShape](https://discourse.processing.org/t/better-color-gradient-for-custom-pshape/19947)

<div class="topic-metadata">

**Author:** [@BennyHacker](https://discourse.processing.org/u/BennyHacker)\
**Replies:** 7\
**Last updated:** [April 25, 2020, 1:56am UTC](https://discourse.processing.org/t/better-color-gradient-for-custom-pshape/19947 "2020-04-25T01:56:55Z")

</div>

Hey forum, I’m having trouble trying to apply a smooth color gradient to a PShape via per vertex shading. Currently I am filling the points based on the angle of each point. As you can see, the gradient appears to confo…

---

## [Help with my Lab](https://discourse.processing.org/t/help-with-my-lab/20111)

<div class="topic-metadata">

**Author:** [@Jonathan25711](https://discourse.processing.org/u/Jonathan25711)\
**Replies:** 4\
**Last updated:** [April 25, 2020, 1:28am UTC](https://discourse.processing.org/t/help-with-my-lab/20111 "2020-04-25T01:28:43Z")

</div>

So I have this code that I’m doing for a lab, thankfully my Comp-Sci teacher gave me some extra time. However, I’m confused about how the code won’t seem to work. It all makes sense to me, so maybe an eye from someone wh…

---

## [Draw a trail of rectangles recursive](https://discourse.processing.org/t/draw-a-trail-of-rectangles-recursive/13149)

<div class="topic-metadata">

**Author:** [@l-arc-en-ciel](https://discourse.processing.org/u/l-arc-en-ciel)\
**Replies:** 6\
**Last updated:** [April 25, 2020, 12:44am UTC](https://discourse.processing.org/t/draw-a-trail-of-rectangles-recursive/13149 "2020-04-25T00:44:14Z")

</div>

I want to draw a trail of rectangles with the latest in the list being in the center of the window. I do this recursively, but I don’t get exactly what I’m doing wrong, since only 2 rectangles are drawn and not 100 (max …

---

## ["Unreachable code" Error When Saving Frames](https://discourse.processing.org/t/unreachable-code-error-when-saving-frames/20082)

<div class="topic-metadata">

**Author:** [@BogginJunior](https://discourse.processing.org/u/BogginJunior)\
**Replies:** 2\
**Last updated:** [April 24, 2020, 1:32am UTC](https://discourse.processing.org/t/unreachable-code-error-when-saving-frames/20082 "2020-04-24T01:32:30Z")

</div>

Hi, When trying to record or saveFrame, I’m shown either “Unreachable code” or “missing active and static modes.” Does anyone know where and how to record the frames of this animation? Thank you. ArrayList\<Circle\> cir…

---

## [Inheritance Class Objects in 2D Grid Array do not align](https://discourse.processing.org/t/inheritance-class-objects-in-2d-grid-array-do-not-align/20081)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 7\
**Last updated:** [April 23, 2020, 10:43pm UTC](https://discourse.processing.org/t/inheritance-class-objects-in-2d-grid-array-do-not-align/20081 "2020-04-23T22:43:40Z")

</div>

I’m trying to get a 2D grid to display properly with 1 subclass object before adding additional subclasses. The code for this 2D array grid is pulled from one of my previous projects, and it worked fine. However, the d…

---

## [Change Saturation of an Image](https://discourse.processing.org/t/change-saturation-of-an-image/20075)

<div class="topic-metadata">

**Author:** [@benprice](https://discourse.processing.org/u/benprice)\
**Replies:** 3\
**Last updated:** [April 23, 2020, 5:25pm UTC](https://discourse.processing.org/t/change-saturation-of-an-image/20075 "2020-04-23T17:25:49Z")

</div>

Hi, I’m trying to figure out how to change the saturation of an image, I can change its brightness, hue, invert it, but just can’t wrap my head around changing saturation (in the hope that i can put it on a slider, and …

---

## [mousePressed - not registering just once](https://discourse.processing.org/t/mousepressed-not-registering-just-once/19096)

<div class="topic-metadata">

**Author:** [@benprice](https://discourse.processing.org/u/benprice)\
**Replies:** 2\
**Last updated:** [April 23, 2020, 3:42pm UTC](https://discourse.processing.org/t/mousepressed-not-registering-just-once/19096 "2020-04-23T15:42:35Z")

</div>

Hi, I’m very new to processing, I’m trying to write a piece of code which plays and pauses a video, and want it so that when i press a certain area of the GUI it pauses the video (and displays a pause symbol) and when p…

---

## [Moving individual object rather than altogether in a for-loop (ArrayList)](https://discourse.processing.org/t/moving-individual-object-rather-than-altogether-in-a-for-loop-arraylist/20039)

<div class="topic-metadata">

**Author:** [@dada123](https://discourse.processing.org/u/dada123)\
**Replies:** 1\
**Last updated:** [April 22, 2020, 7:27pm UTC](https://discourse.processing.org/t/moving-individual-object-rather-than-altogether-in-a-for-loop-arraylist/20039 "2020-04-22T19:27:47Z")

</div>

hi, i am trying to get this moved individually instead of moving altogether at once. my objects are created in a loop, is there a way to get them to move individually instead? here’s my code, thanks in advanced! public …

---

## [Animated curves with beginShape()](https://discourse.processing.org/t/animated-curves-with-beginshape/19971)

<div class="topic-metadata">

**Author:** [@jeffthompson](https://discourse.processing.org/u/jeffthompson)\
**Replies:** 5\
**Last updated:** [April 22, 2020, 3:29pm UTC](https://discourse.processing.org/t/animated-curves-with-beginshape/19971 "2020-04-22T15:29:44Z")

</div>

I have a series of points forming a complex curve that I’d like to animate – essentially we see the curve being drawn point-by-point. But if I use curveVertex() and begin/endShape() but end drawing the line early, the un…

---

## [LinkedList vs ArrayList](https://discourse.processing.org/t/linkedlist-vs-arraylist/19946)

<div class="topic-metadata">

**Author:** [@noel](https://discourse.processing.org/u/noel)\
**Replies:** 21\
**Last updated:** [April 22, 2020, 11:33am UTC](https://discourse.processing.org/t/linkedlist-vs-arraylist/19946 "2020-04-22T11:33:12Z")

</div>

Code below is perfectly working, but unfortunately, OpenProcessing does not accept the LinkedList import. The other imports seem to be accepted. I would like to use ArrayList instead, but I get the “does not match” erro…

---

## [Using an integer to manipulate a string/text variable](https://discourse.processing.org/t/using-an-integer-to-manipulate-a-string-text-variable/20015)

<div class="topic-metadata">

**Author:** [@nathanprime1](https://discourse.processing.org/u/nathanprime1)\
**Replies:** 1\
**Last updated:** [April 22, 2020, 10:40am UTC](https://discourse.processing.org/t/using-an-integer-to-manipulate-a-string-text-variable/20015 "2020-04-22T10:40:15Z")

</div>

Write a function that consumes a non-negative integer k and prints a k-size diamond. A k-size diamond consists of a top, a middle and a bottom. The middle is a single row of 2k+1 d’s. The top consists of k rows. The i th…

---

## [Spreading out points](https://discourse.processing.org/t/spreading-out-points/19980)

<div class="topic-metadata">

**Author:** [@yuyu\_hakusho](https://discourse.processing.org/u/yuyu_hakusho)\
**Replies:** 3\
**Last updated:** [April 21, 2020, 3:49pm UTC](https://discourse.processing.org/t/spreading-out-points/19980 "2020-04-21T15:49:18Z")

</div>

Hi everyone, I need some help with the traveling salesman problem. The issue I am having is that the (x, y) points of each city are too close to each other. As such, I get the result in the image below. Is there a way I …

---

## [Group collision detection](https://discourse.processing.org/t/group-collision-detection/19956)

<div class="topic-metadata">

**Author:** [@mala](https://discourse.processing.org/u/mala)\
**Replies:** 3\
**Last updated:** [April 21, 2020, 1:42pm UTC](https://discourse.processing.org/t/group-collision-detection/19956 "2020-04-21T13:42:07Z")

</div>

For a while I’ve been trying to fix & improve some code that uses some form of collision detection for a user chosen and variable group of objects, these are all the same size and aligned to a grid. The user should be a…

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

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