# Coding Questions

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

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

**Page:** 46

---

## [B-splines implementation](https://discourse.processing.org/t/b-splines-implementation/31991)

<div class="topic-metadata">

**Author:** [@molo32](https://discourse.processing.org/u/molo32)\
**Replies:** 2\
**Last updated:** [September 2, 2021, 10:11pm UTC](https://discourse.processing.org/t/b-splines-implementation/31991 "2021-09-02T22:11:42Z")

</div>

I am trying to draw a b-spline, i don’t want to use third party libraries I want to implement it myself., the code below does not work correctly. control point px \[0\] p and \[0\] appears to be at 0.0. but it should be x …

---

## [Gradient with lines](https://discourse.processing.org/t/gradient-with-lines/32035)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 4\
**Last updated:** [September 2, 2021, 7:37pm UTC](https://discourse.processing.org/t/gradient-with-lines/32035 "2021-09-02T19:37:07Z")

</div>

Hi there! I have found an interesting way to create gradients with lines in a tutorial. size (900, 900); background (255); colorMode(HSB,360,100,100); for (int i = 0; i \< 300; i++) { stroke(i,100,100); line(0, i, 1000,…

---

## [Why is built-in bezier function more smooth than my custom bezier function?](https://discourse.processing.org/t/why-is-built-in-bezier-function-more-smooth-than-my-custom-bezier-function/31833)

<div class="topic-metadata">

**Author:** [@ibrahimak](https://discourse.processing.org/u/ibrahimak)\
**Replies:** 6\
**Last updated:** [August 25, 2021, 10:39am UTC](https://discourse.processing.org/t/why-is-built-in-bezier-function-more-smooth-than-my-custom-bezier-function/31833 "2021-08-25T10:39:28Z")

</div>

I’ve a linear interpolate function: Vector2 linearInterpolate(Vector2 p1, Vector2 p2, float value) { return p1.add(p2.sub(p1).mult(value)); } I’ve quadratic bezier curve function: Vector2 quadraticBezier(Vector2 p1,…

---

## [I want to change the Flocking](https://discourse.processing.org/t/i-want-to-change-the-flocking/32005)

<div class="topic-metadata">

**Author:** [@aug](https://discourse.processing.org/u/aug)\
**Replies:** 5\
**Last updated:** [September 2, 2021, 8:15am UTC](https://discourse.processing.org/t/i-want-to-change-the-flocking/32005 "2021-09-02T08:15:37Z")

</div>

I want to change the weight of cohesion only for the agent added by clicking in the sample code of Flocking. How do I change the code?

---

## [Writing to CSV, new set of rows each day, is it possible?](https://discourse.processing.org/t/writing-to-csv-new-set-of-rows-each-day-is-it-possible/32018)

<div class="topic-metadata">

**Author:** [@laptophead](https://discourse.processing.org/u/laptophead)\
**Replies:** 5\
**Last updated:** [September 1, 2021, 8:35pm UTC](https://discourse.processing.org/t/writing-to-csv-new-set-of-rows-each-day-is-it-possible/32018 "2021-09-01T20:35:02Z")

</div>

I have this recording function that updates every 5 sec and records data as such: void SaveToFile () { //table.clearRows(); //newRow.setInt("MACH ID", table.getRowCount() - 1); for (int i=1; i\<=10; i++) {Tabl…

---

## [Is there a better way to compare multiple Strings?](https://discourse.processing.org/t/is-there-a-better-way-to-compare-multiple-strings/32024)

<div class="topic-metadata">

**Author:** [@chaotic](https://discourse.processing.org/u/chaotic)\
**Replies:** 4\
**Last updated:** [September 1, 2021, 7:17pm UTC](https://discourse.processing.org/t/is-there-a-better-way-to-compare-multiple-strings/32024 "2021-09-01T19:17:46Z")

</div>

I’m trying to write a code that will only allow you to enter certain numbers. I found a way but I feel like there should be a more efficient way. String text=""; String saved=""; String degree90="90"; String degree89="8…

---

## [How to improve movement with keys?](https://discourse.processing.org/t/how-to-improve-movement-with-keys/31856)

<div class="topic-metadata">

**Author:** [@Braunstein](https://discourse.processing.org/u/Braunstein)\
**Replies:** 9\
**Last updated:** [September 1, 2021, 2:44pm UTC](https://discourse.processing.org/t/how-to-improve-movement-with-keys/31856 "2021-09-01T14:44:52Z")

</div>

Heya, i picked up a project again that i dropped a while ago, and it includes a playable figure that is steered with w, a, s and d. But i noticed how the player would first kinda spazz out and then change direction with …

---

## [Select one button from button object array](https://discourse.processing.org/t/select-one-button-from-button-object-array/32034)

<div class="topic-metadata">

**Author:** [@Naison](https://discourse.processing.org/u/Naison)\
**Replies:** 2\
**Last updated:** [September 1, 2021, 8:47am UTC](https://discourse.processing.org/t/select-one-button-from-button-object-array/32034 "2021-09-01T08:47:25Z")

</div>

Hey guys! I’m just experimenting with how to code a system that selects one from multiple buttons in your sketch if clicked on one button and deselects it when clicked on another button so that always just one or none bu…

---

## [How to check if all elements in an array are the same?](https://discourse.processing.org/t/how-to-check-if-all-elements-in-an-array-are-the-same/32044)

<div class="topic-metadata">

**Author:** [@lucaswoah](https://discourse.processing.org/u/lucaswoah)\
**Replies:** 2\
**Last updated:** [September 1, 2021, 5:59am UTC](https://discourse.processing.org/t/how-to-check-if-all-elements-in-an-array-are-the-same/32044 "2021-09-01T05:59:50Z")

</div>

I made this game for my exam where I have this two dimensional (int \[\] \[\] M = new int \[30\]\[30\]) array that has 3 possible values: 0 (black tile), 1 (white tile) and 2 (fruits). The player can click with the left mouse bu…

---

## [How to add score and ending to my game](https://discourse.processing.org/t/how-to-add-score-and-ending-to-my-game/13235)

<div class="topic-metadata">

**Author:** [@Mike92](https://discourse.processing.org/u/Mike92)\
**Replies:** 12\
**Last updated:** [November 3, 2020, 12:22am UTC](https://discourse.processing.org/t/how-to-add-score-and-ending-to-my-game/13235 "2020-11-03T00:22:38Z")

</div>

Hi all, I’m new on this forum. I’ve writing my first game to processing and I’m trying to add score and ending to my game. I’ve just add some lines of code but don’t work. Someone can help me? Here the code: float x = …

---

## [Instantiate class from string](https://discourse.processing.org/t/instantiate-class-from-string/32006)

<div class="topic-metadata">

**Author:** [@molo32](https://discourse.processing.org/u/molo32)\
**Replies:** 2\
**Last updated:** [August 31, 2021, 3:02pm UTC](https://discourse.processing.org/t/instantiate-class-from-string/32006 "2021-08-31T15:02:25Z")

</div>

I googled methods but couldn’t get it to work in processing. what I’m looking for is something like. String s="foo"; void setup(){ parent new\_instance= new s; } class parent{ } class foo extends parent{ }

---

## [Problem with keyPressed() and SPACE](https://discourse.processing.org/t/problem-with-keypressed-and-space/7468)

<div class="topic-metadata">

**Author:** [@JoLi](https://discourse.processing.org/u/JoLi)\
**Replies:** 2\
**Last updated:** [October 27, 2020, 3:52pm UTC](https://discourse.processing.org/t/problem-with-keypressed-and-space/7468 "2020-10-27T15:52:32Z")

</div>

I am new here and with Processing. My Problem is: void keyPressed() { if(key == SPACE) { ellipse(10, 10, 20, 20); } } Processing “says” that “SPACE” is an invalid character constant. I also tried these: void key…

---

## [Slow down an animation](https://discourse.processing.org/t/slow-down-an-animation/10381)

<div class="topic-metadata">

**Author:** [@vincentstrebelle](https://discourse.processing.org/u/vincentstrebelle)\
**Replies:** 16\
**Last updated:** [March 5, 2021, 12:24pm UTC](https://discourse.processing.org/t/slow-down-an-animation/10381 "2021-03-05T12:24:49Z")

</div>

Hi, i found the sequential example to make an animation and i wonder how can i slow down the animation without change the framerate. Is that possible ? here is the example: (https://processing.org/examples/sequential.ht…

---

## [Create 8 clickable circles](https://discourse.processing.org/t/create-8-clickable-circles/32002)

<div class="topic-metadata">

**Author:** [@jhsa](https://discourse.processing.org/u/jhsa)\
**Replies:** 13\
**Last updated:** [August 30, 2021, 2:33am UTC](https://discourse.processing.org/t/create-8-clickable-circles/32002 "2021-08-30T02:33:21Z")

</div>

I have been looking for examples on how to draw 8 clickable circles. The idea is to emulate 8 LEDs, and turn them ON/OFF when clicking on them with the mouse. I have been playing with the example I found (that one with …

---

## [Copy image from clipboard processing 3.x](https://discourse.processing.org/t/copy-image-from-clipboard-processing-3-x/31994)

<div class="topic-metadata">

**Author:** [@robottini](https://discourse.processing.org/u/robottini)\
**Replies:** 1\
**Last updated:** [August 29, 2021, 9:59am UTC](https://discourse.processing.org/t/copy-image-from-clipboard-processing-3-x/31994 "2021-08-29T09:59:20Z")

</div>

Hi I have this code for clipboard image copy to processing. It works well for processing 2.x but not for processing 3.x. I know that java.awt.Applet is no longer the base class used by PApplet, but I can’t identify an al…

---

## [Loops with diagonal queues](https://discourse.processing.org/t/loops-with-diagonal-queues/31850)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 18\
**Last updated:** [August 26, 2021, 4:01pm UTC](https://discourse.processing.org/t/loops-with-diagonal-queues/31850 "2021-08-26T16:01:53Z")

</div>

Hi there! I am learning about loops with “for” with a useful tutorial. I have made a pattern with few lines of code (amazing!). But the pattern that I really want to do has diagonal lines of points, as you can see on the…

---

## [Getting PShape vertex coordinates relative to scene](https://discourse.processing.org/t/getting-pshape-vertex-coordinates-relative-to-scene/31981)

<div class="topic-metadata">

**Author:** [@dehyde](https://discourse.processing.org/u/dehyde)\
**Replies:** 1\
**Last updated:** [August 28, 2021, 12:07pm UTC](https://discourse.processing.org/t/getting-pshape-vertex-coordinates-relative-to-scene/31981 "2021-08-28T12:07:02Z")

</div>

Hi all :slight\_smile: The problem: I’m trying to get set of 3 groups of 3 floats that the relationship between them is a representation of equilateral triangle in a limited space (each number 0.0-\>0.1). x1,y1,z1 x2,y2…

---

## [Is there an elegant way to generate the permutations of all the members of a set?](https://discourse.processing.org/t/is-there-an-elegant-way-to-generate-the-permutations-of-all-the-members-of-a-set/31810)

<div class="topic-metadata">

**Author:** [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Replies:** 26\
**Last updated:** [August 28, 2021, 4:36am UTC](https://discourse.processing.org/t/is-there-an-elegant-way-to-generate-the-permutations-of-all-the-members-of-a-set/31810 "2021-08-28T04:36:23Z")

</div>

Is there an elegant way to use Processing to generate the permutations of all the members of a set? I have done it in a long winded, clumsy, inelegant way for six elements by having an array of all 720 permutation of si…

---

## [How make the display window no overlap the text editor window?](https://discourse.processing.org/t/how-make-the-display-window-no-overlap-the-text-editor-window/31840)

<div class="topic-metadata">

**Author:** [@AshSnaga](https://discourse.processing.org/u/AshSnaga)\
**Replies:** 1\
**Last updated:** [August 22, 2021, 8:19pm UTC](https://discourse.processing.org/t/how-make-the-display-window-no-overlap-the-text-editor-window/31840 "2021-08-22T20:19:26Z")

</div>

Hi, there. I had this excruciating problem :wink: I want to see both windows at the same time when coding. Each time I run a sketch I must move the display window to see the text editor window. I know that people work w…

---

## [Getting A Sketch's Window's Position](https://discourse.processing.org/t/getting-a-sketchs-windows-position/31772)

<div class="topic-metadata">

**Author:** [@s31](https://discourse.processing.org/u/s31)\
**Replies:** 6\
**Last updated:** [August 27, 2021, 9:27pm UTC](https://discourse.processing.org/t/getting-a-sketchs-windows-position/31772 "2021-08-27T21:27:51Z")

</div>

Hello, I’ve been searching for an answer to this for a while now and have been unable to find any solutions that work for the most recent versions of processing. Does anyone know how you would get the X and Y coordinate…

---

## [How to fade between multiple colors?](https://discourse.processing.org/t/how-to-fade-between-multiple-colors/31968)

<div class="topic-metadata">

**Author:** [@jimjimmer](https://discourse.processing.org/u/jimjimmer)\
**Replies:** 4\
**Last updated:** [August 27, 2021, 7:28pm UTC](https://discourse.processing.org/t/how-to-fade-between-multiple-colors/31968 "2021-08-27T19:28:46Z")

</div>

Hi I can understand how to fade from one color (and back again) using code such as the one bellow. But what if I want to move through a series of 3 or more color’s? Have you managed it?? ; void setup() { size ( 300,…

---

## [Collision in 2D-Game](https://discourse.processing.org/t/collision-in-2d-game/31914)

<div class="topic-metadata">

**Author:** [@Braunstein](https://discourse.processing.org/u/Braunstein)\
**Replies:** 3\
**Last updated:** [August 27, 2021, 10:01am UTC](https://discourse.processing.org/t/collision-in-2d-game/31914 "2021-08-27T10:01:15Z")

</div>

Heya, i have been making some progress on a 2D-open-world-“game”. So far, you can move into eight directions (thanks to the user @CodeMasterX) on a 200000 by 200000 pixel world and increase your speed by holding the spri…

---

## [Random rows/columns in a csv file and print text with typewriter effect](https://discourse.processing.org/t/random-rows-columns-in-a-csv-file-and-print-text-with-typewriter-effect/12889)

<div class="topic-metadata">

**Author:** [@OptOut](https://discourse.processing.org/u/OptOut)\
**Replies:** 82\
**Last updated:** [August 26, 2021, 5:38pm UTC](https://discourse.processing.org/t/random-rows-columns-in-a-csv-file-and-print-text-with-typewriter-effect/12889 "2021-08-26T17:38:34Z")

</div>

Hi all, I am starting on a project that involves using data from a large csv. For now I am just playing with the processing Table/row documentation and have created a mammals.csv file containing amount, species, name …

---

## [Problems with exporting to SVG](https://discourse.processing.org/t/problems-with-exporting-to-svg/31950)

<div class="topic-metadata">

**Author:** [@liogra](https://discourse.processing.org/u/liogra)\
**Replies:** 4\
**Last updated:** [August 26, 2021, 4:00pm UTC](https://discourse.processing.org/t/problems-with-exporting-to-svg/31950 "2021-08-26T16:00:37Z")

</div>

Quite new to processing so might be overlooking something. I’m trying to export the following as SVG. but it hangs at the for statements. also tried without screen display but that is also not working. PImage img; impo…

---

## [Problem with translate() in class when using arraylist](https://discourse.processing.org/t/problem-with-translate-in-class-when-using-arraylist/31732)

<div class="topic-metadata">

**Author:** [@chaotic.rabbit](https://discourse.processing.org/u/chaotic.rabbit)\
**Replies:** 8\
**Last updated:** [August 26, 2021, 8:46am UTC](https://discourse.processing.org/t/problem-with-translate-in-class-when-using-arraylist/31732 "2021-08-26T08:46:41Z")

</div>

Hi, I really need help with this code. I’ve been trying to make infinite jellyfish appear from the bottom of the screen and move upwards until they disappear. For some reason after a while the jellyfish start appearing f…

---

## [Controlling drawing speed](https://discourse.processing.org/t/controlling-drawing-speed/31929)

<div class="topic-metadata">

**Author:** [@mews](https://discourse.processing.org/u/mews)\
**Replies:** 2\
**Last updated:** [August 26, 2021, 1:13am UTC](https://discourse.processing.org/t/controlling-drawing-speed/31929 "2021-08-26T01:13:04Z")

</div>

Hi Folks, I’m having a bit of an issue which I feel is probably simple but I’m just not getting it. I’m trying to make a simple Missile Control clone where missiles are drawn via a basic line drawing algorithm. They com…

---

## [How to assign random colors to multiple objects](https://discourse.processing.org/t/how-to-assign-random-colors-to-multiple-objects/31919)

<div class="topic-metadata">

**Author:** [@jimjimmer](https://discourse.processing.org/u/jimjimmer)\
**Replies:** 3\
**Last updated:** [August 25, 2021, 1:33pm UTC](https://discourse.processing.org/t/how-to-assign-random-colors-to-multiple-objects/31919 "2021-08-25T13:33:38Z")

</div>

I’m trying to write a code which draws a circle at each of a series of coordinates given from a csv file. I want to give each circle a random color but my code at present gives the same color to all the circles. How ca…

---

## [How to combine mouse history code and mouseXY-based rotation code](https://discourse.processing.org/t/how-to-combine-mouse-history-code-and-mousexy-based-rotation-code/31910)

<div class="topic-metadata">

**Author:** [@wwoni](https://discourse.processing.org/u/wwoni)\
**Replies:** 0\
**Last updated:** [August 25, 2021, 4:43am UTC](https://discourse.processing.org/t/how-to-combine-mouse-history-code-and-mousexy-based-rotation-code/31910 "2021-08-25T04:43:03Z")

</div>

Hello, I am a self-taught student. I’d like to combine the mouse history code and mouse rotation code below. But when I put it together, the larger the x- and y-coordinates of the mousexy, the farther away the object i…

---

## [Rotate and move java processing](https://discourse.processing.org/t/rotate-and-move-java-processing/31773)

<div class="topic-metadata">

**Author:** [@ctremblay](https://discourse.processing.org/u/ctremblay)\
**Replies:** 8\
**Last updated:** [August 23, 2021, 8:14pm UTC](https://discourse.processing.org/t/rotate-and-move-java-processing/31773 "2021-08-23T20:14:02Z")

</div>

I’m trying to make a space invaders game, but when I rotate I’m getting weird results. First it moving up like I want it to but when i rotate it starts moving sideways or even backwards. Can someone explain why it wont f…

---

## [I can't apply textures to custom PShapes](https://discourse.processing.org/t/i-cant-apply-textures-to-custom-pshapes/31863)

<div class="topic-metadata">

**Author:** [@Math\_Machine](https://discourse.processing.org/u/Math_Machine)\
**Replies:** 2\
**Last updated:** [August 23, 2021, 6:08pm UTC](https://discourse.processing.org/t/i-cant-apply-textures-to-custom-pshapes/31863 "2021-08-23T18:08:08Z")

</div>

TLDR: Can you apply a texture spherically to an arbitrary instance of PShape? So, I’ve been writing code to make a solar system model. Recently, I added in Mars’s moons, Phobos and Deimos. Which, unlike everything els…

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

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