# Coding Questions

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

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

**Page:** 47

---

## [Pixelation on my sketches](https://discourse.processing.org/t/pixelation-on-my-sketches/31862)

<div class="topic-metadata">

**Author:** [@Tito\_Long](https://discourse.processing.org/u/Tito_Long)\
**Replies:** 1\
**Last updated:** [August 23, 2021, 3:05pm UTC](https://discourse.processing.org/t/pixelation-on-my-sketches/31862 "2021-08-23T15:05:05Z")

</div>

Hi There, total beginner to processing! I’ve been playing around with the program and all of a sudden my sketches have become pixelated when I preview them (please see screenshot attached). I’m using the exact same code…

---

## [Move triangle up and down using 'w' and 's' keys](https://discourse.processing.org/t/move-triangle-up-and-down-using-w-and-s-keys/31855)

<div class="topic-metadata">

**Author:** [@NewCoder1](https://discourse.processing.org/u/NewCoder1)\
**Replies:** 1\
**Last updated:** [August 23, 2021, 10:21am UTC](https://discourse.processing.org/t/move-triangle-up-and-down-using-w-and-s-keys/31855 "2021-08-23T10:21:18Z")

</div>

Hey I need help with moving my triangle up and down using the ‘w’ and ‘s’ keys. I’ve tried many different types of codes such as using keyPressed, etc but it hasn’t worked out for me. This is what I have at the moment s…

---

## [Creating dynamic array](https://discourse.processing.org/t/creating-dynamic-array/31794)

<div class="topic-metadata">

**Author:** [@yalaniv](https://discourse.processing.org/u/yalaniv)\
**Replies:** 11\
**Last updated:** [August 22, 2021, 4:42pm UTC](https://discourse.processing.org/t/creating-dynamic-array/31794 "2021-08-22T16:42:22Z")

</div>

I am missing some commands, so if you can help me - that would be awesome. I want to creat a dynamic array, that stores the keypressed, and how many times each one pressed for example, let’s say the user pressed the ke…

---

## [How to apply color quantization to an image](https://discourse.processing.org/t/how-to-apply-color-quantization-to-an-image/4849)

<div class="topic-metadata">

**Author:** [@BulVvyvXsWDYZl8J](https://discourse.processing.org/u/BulVvyvXsWDYZl8J)\
**Replies:** 26\
**Last updated:** [August 20, 2021, 8:15pm UTC](https://discourse.processing.org/t/how-to-apply-color-quantization-to-an-image/4849 "2021-08-20T20:15:39Z")

</div>

Is there a simple way (preferably a function) to apply color quantization to an image? Specifically I’d like to pick a PImage and an int of colours, and it’d reduce the number of colours to that int, trying to keep it as…

---

## [Confine particles to a space](https://discourse.processing.org/t/confine-particles-to-a-space/31813)

<div class="topic-metadata">

**Author:** [@seldomcoder](https://discourse.processing.org/u/seldomcoder)\
**Replies:** 2\
**Last updated:** [August 20, 2021, 7:16pm UTC](https://discourse.processing.org/t/confine-particles-to-a-space/31813 "2021-08-20T19:16:34Z")

</div>

I want to confine the particles and emergent lines (in the code) to a specific space like an annular ring between two concentric circles. Now, the particles and lines are all over the canvas. How do I go about that? //…

---

## [Export exe. from processing 3.5.4](https://discourse.processing.org/t/export-exe-from-processing-3-5-4/31783)

<div class="topic-metadata">

**Author:** [@CHI123](https://discourse.processing.org/u/CHI123)\
**Replies:** 7\
**Last updated:** [August 19, 2021, 9:45pm UTC](https://discourse.processing.org/t/export-exe-from-processing-3-5-4/31783 "2021-08-19T21:45:12Z")

</div>

Hi, I am not sure where to post this question. If it is wrong, kindly tell me. I export the exe. from my sketch. Like in the following picture. link: https://forum.processing.org/two/discussion/27156/application-ex…

---

## [Some problem with shadertoy to processing！](https://discourse.processing.org/t/some-problem-with-shadertoy-to-processing/31742)

<div class="topic-metadata">

**Author:** [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Replies:** 17\
**Last updated:** [August 19, 2021, 8:31am UTC](https://discourse.processing.org/t/some-problem-with-shadertoy-to-processing/31742 "2021-08-19T08:31:37Z")

</div>

Hi guys! I am learning something about the shader. I try to convert the code from shadertoy to processing, but it seems that everything is ok but it runs without any effect. Can anyone give some suggestions? This is pr…

---

## [Exporting still images from animations](https://discourse.processing.org/t/exporting-still-images-from-animations/31666)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 23\
**Last updated:** [August 18, 2021, 11:17am UTC](https://discourse.processing.org/t/exporting-still-images-from-animations/31666 "2021-08-18T11:17:40Z")

</div>

Hi there ! I want to export still images from this animation and I don’t know how to do it. This code make interesting images in different moments and I would like to frozen and export them to print them in HQ. Could yo…

---

## [Convert digital photo into digital](https://discourse.processing.org/t/convert-digital-photo-into-digital/31745)

<div class="topic-metadata">

**Author:** [@yalaniv](https://discourse.processing.org/u/yalaniv)\
**Replies:** 2\
**Last updated:** [August 16, 2021, 5:37pm UTC](https://discourse.processing.org/t/convert-digital-photo-into-digital/31745 "2021-08-16T17:37:05Z")

</div>

I would like to import an image, and manipulate it in order to make it look like it created with digital tools. I found a code about how to convert full color image into gray scale one, but I am kinda stuck with the di…

---

## [Applying power by amount of time passed?](https://discourse.processing.org/t/applying-power-by-amount-of-time-passed/30295)

<div class="topic-metadata">

**Author:** [@int](https://discourse.processing.org/u/int)\
**Replies:** 5\
**Last updated:** [August 16, 2021, 12:35pm UTC](https://discourse.processing.org/t/applying-power-by-amount-of-time-passed/30295 "2021-08-16T12:35:15Z")

</div>

Hi, I’m struggling to figure out how you can set the speed/power of a moving object based on time. For example, When you press a key, a ball is thrown from one end to the other. the time taken to press the key is calcula…

---

## [Why updating sand simulation in grid doesn't work?](https://discourse.processing.org/t/why-updating-sand-simulation-in-grid-doesnt-work/31722)

<div class="topic-metadata">

**Author:** [@Rafsing](https://discourse.processing.org/u/Rafsing)\
**Replies:** 2\
**Last updated:** [August 15, 2021, 1:19am UTC](https://discourse.processing.org/t/why-updating-sand-simulation-in-grid-doesnt-work/31722 "2021-08-15T01:19:17Z")

</div>

I want to make a falling sand simulation using cellular automata, but when I update it, nothing happens, and when I want to do a line of diffrent material using lineDrawing() this material appear in random cells. This is…

---

## [Calling different draw functions](https://discourse.processing.org/t/calling-different-draw-functions/31709)

<div class="topic-metadata">

**Author:** [@odecode](https://discourse.processing.org/u/odecode)\
**Replies:** 15\
**Last updated:** [August 14, 2021, 6:38pm UTC](https://discourse.processing.org/t/calling-different-draw-functions/31709 "2021-08-14T18:38:34Z")

</div>

Hello! I followed TheCodingTrain’s youtube video for the Rubik’s cube, and am now adding some functionality which I need help with. I am using java mode. I created a simple solver (brute force), and now I want to create …

---

## [How to create a line in a grid using Bresenham's line algorithm](https://discourse.processing.org/t/how-to-create-a-line-in-a-grid-using-bresenhams-line-algorithm/31721)

<div class="topic-metadata">

**Author:** [@Rafsing](https://discourse.processing.org/u/Rafsing)\
**Replies:** 1\
**Last updated:** [August 14, 2021, 12:43am UTC](https://discourse.processing.org/t/how-to-create-a-line-in-a-grid-using-bresenhams-line-algorithm/31721 "2021-08-14T00:43:20Z")

</div>

I want to create a line using Bresenham’s algorithm , but the only line that works is a horizontal line from left to right, lines pointing upwards do not work at all and lines drawn diagonally downwards appear in the wro…

---

## [How to save frames with many transparent images?](https://discourse.processing.org/t/how-to-save-frames-with-many-transparent-images/30522)

<div class="topic-metadata">

**Author:** [@noodleSystem](https://discourse.processing.org/u/noodleSystem)\
**Replies:** 10\
**Last updated:** [August 13, 2021, 7:45pm UTC](https://discourse.processing.org/t/how-to-save-frames-with-many-transparent-images/30522 "2021-08-13T19:45:35Z")

</div>

This is kind of a weird question, please forgive the longwinded explanation: There must be an easier way to do this. I’m trying to save each frame (as it appears on the screen) and make a movie, but the frame captures t…

---

## [I need random shapes to appear in a random order](https://discourse.processing.org/t/i-need-random-shapes-to-appear-in-a-random-order/31716)

<div class="topic-metadata">

**Author:** [@maroslan](https://discourse.processing.org/u/maroslan)\
**Replies:** 2\
**Last updated:** [August 13, 2021, 6:17pm UTC](https://discourse.processing.org/t/i-need-random-shapes-to-appear-in-a-random-order/31716 "2021-08-13T18:17:36Z")

</div>

Hi everyone For an assignment I am trying to make two shapes (ellipse and rectangle) appear in a random order (with random color and position). The color and position I got down, but I cannot seem to seperate the ellip…

---

## [Would you call this way to measure velocity "correct"?](https://discourse.processing.org/t/would-you-call-this-way-to-measure-velocity-correct/31697)

<div class="topic-metadata">

**Author:** [@G03TH3](https://discourse.processing.org/u/G03TH3)\
**Replies:** 3\
**Last updated:** [August 13, 2021, 9:27am UTC](https://discourse.processing.org/t/would-you-call-this-way-to-measure-velocity-correct/31697 "2021-08-13T09:27:50Z")

</div>

float x; float playbackSpeed; float x\_po, pr\_x, pa\_x, x\_d; float prevTime = 0; float dt, velocity = 1; float currTime; void setup() { size(640, 360); background(255); } void draw() { x\_po+=10; // X1-POSITION if…

---

## [Making my float increase then decrease so that my ellipses grows and then shrinks](https://discourse.processing.org/t/making-my-float-increase-then-decrease-so-that-my-ellipses-grows-and-then-shrinks/31701)

<div class="topic-metadata">

**Author:** [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Replies:** 7\
**Last updated:** [August 13, 2021, 8:00am UTC](https://discourse.processing.org/t/making-my-float-increase-then-decrease-so-that-my-ellipses-grows-and-then-shrinks/31701 "2021-08-13T08:00:51Z")

</div>

Here is the code I use to make ellipses grow and then shrink. I have already declared vision as a float with the starting value 0; if (circleIsShrinking) vision = vision -0,2; else vision = vision +0,2; if (…

---

## [Give sound to AI paths](https://discourse.processing.org/t/give-sound-to-ai-paths/31660)

<div class="topic-metadata">

**Author:** [@markelloskolofotias](https://discourse.processing.org/u/markelloskolofotias)\
**Replies:** 4\
**Last updated:** [August 12, 2021, 5:48pm UTC](https://discourse.processing.org/t/give-sound-to-ai-paths/31660 "2021-08-12T17:48:43Z")

</div>

Dear community, I am a postgraduate fine art student from Greece and I have a question for you. I designed the following symbols in Adobe Illustrator and I would like to give them sound. So, could you please tell me i…

---

## [Trying to make a animation where it gradually grows and then shrinks but it bugs](https://discourse.processing.org/t/trying-to-make-a-animation-where-it-gradually-grows-and-then-shrinks-but-it-bugs/31690)

<div class="topic-metadata">

**Author:** [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Replies:** 3\
**Last updated:** [August 12, 2021, 8:20am UTC](https://discourse.processing.org/t/trying-to-make-a-animation-where-it-gradually-grows-and-then-shrinks-but-it-bugs/31690 "2021-08-12T08:20:54Z")

</div>

if (vision \< 150) { vision\_speed = 1; } if (vision \> 250) { vision\_speed = -1; } vision = vision + vision\_speed; //////////////////////////////////////////// The growing and shrinking par…

---

## [Close the full screen second window through keyboard or through parent window?](https://discourse.processing.org/t/close-the-full-screen-second-window-through-keyboard-or-through-parent-window/10571)

<div class="topic-metadata">

**Author:** [@stan\_11](https://discourse.processing.org/u/stan_11)\
**Replies:** 3\
**Last updated:** [August 11, 2021, 8:55am UTC](https://discourse.processing.org/t/close-the-full-screen-second-window-through-keyboard-or-through-parent-window/10571 "2021-08-11T08:55:08Z")

</div>

Here is my code PWindow win; public void settings() { size(320, 240); } void setup() { surface.setLocation(20,20); //win = new PWindow(); } void draw() { background(255, 0, 0); fill(255); rect(10, 10…

---

## [Detect shapes split by intersecting lines](https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641)

<div class="topic-metadata">

**Author:** [@hkjung](https://discourse.processing.org/u/hkjung)\
**Replies:** 4\
**Last updated:** [August 10, 2021, 6:47pm UTC](https://discourse.processing.org/t/detect-shapes-split-by-intersecting-lines/31641 "2021-08-10T18:47:00Z")

</div>

I want to detect separate shapes as lines split the canvas. I saved line intersection points in the list of PVectors, but don’t know how to connect points that complete split shapes separately. Here’s a sample image tha…

---

## [How to copy the contents of a website](https://discourse.processing.org/t/how-to-copy-the-contents-of-a-website/31646)

<div class="topic-metadata">

**Author:** [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Replies:** 2\
**Last updated:** [August 10, 2021, 11:48am UTC](https://discourse.processing.org/t/how-to-copy-the-contents-of-a-website/31646 "2021-08-10T11:48:50Z")

</div>

Hi! I want to open a link and copy the contents of the website. I do not care if it is HTML code or if I just copy the contents with right click, the only thing I need is automation. I want to copy everything between St…

---

## [Do i need to upgrade Sketch?](https://discourse.processing.org/t/do-i-need-to-upgrade-sketch/31645)

<div class="topic-metadata">

**Author:** [@sjriga](https://discourse.processing.org/u/sjriga)\
**Replies:** 1\
**Last updated:** [August 9, 2021, 2:31pm UTC](https://discourse.processing.org/t/do-i-need-to-upgrade-sketch/31645 "2021-08-09T14:31:47Z")

</div>

Hi, I’m unable to render 3D in my current version of Sketch, where/how do I upgrade?

---

## [How to make my rects bigger based on proximity (bigger the closer to my mouse) pjs](https://discourse.processing.org/t/how-to-make-my-rects-bigger-based-on-proximity-bigger-the-closer-to-my-mouse-pjs/31637)

<div class="topic-metadata">

**Author:** [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Replies:** 15\
**Last updated:** [August 9, 2021, 10:50am UTC](https://discourse.processing.org/t/how-to-make-my-rects-bigger-based-on-proximity-bigger-the-closer-to-my-mouse-pjs/31637 "2021-08-09T10:50:22Z")

</div>

void setup() { frameRate(60); size(1020, 510); } void draw() { background(0); int spacing\_x = 45; int spacing\_y = 45; for (int x = 0; x \< width + spacing\_x; x = x + spacing\_x) { for (int y = 0; y \< …

---

## [Loops using arrays](https://discourse.processing.org/t/loops-using-arrays/30253)

<div class="topic-metadata">

**Author:** [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Replies:** 8\
**Last updated:** [August 9, 2021, 10:13am UTC](https://discourse.processing.org/t/loops-using-arrays/30253 "2021-08-09T10:13:05Z")

</div>

what is wrong with this code? Why does not the ellipses change colors? \< color c\[\]; int x = 0; void setup() { size(400,400); c\[0\]=color(255, 0, 0); // first color c\[1\]=color(0, 255, 0); // second c\[2\]=color(0, 0,…

---

## [How to add to an ArrayList every x seconds?](https://discourse.processing.org/t/how-to-add-to-an-arraylist-every-x-seconds/31609)

<div class="topic-metadata">

**Author:** [@chaotic.rabbit](https://discourse.processing.org/u/chaotic.rabbit)\
**Replies:** 1\
**Last updated:** [August 7, 2021, 11:29am UTC](https://discourse.processing.org/t/how-to-add-to-an-arraylist-every-x-seconds/31609 "2021-08-07T11:29:14Z")

</div>

void setup(){ jellies = new ArrayList(); for(int i=0; i\<=5; i++){ jellies.add(new Jellyfish(random(0, 800), random(height), random(-40, 40), random(0.05, 0.35))); } for(int i = jellies.size()-1; i\>=0; i–){ Jellyfis…

---

## [For loop matrix index](https://discourse.processing.org/t/for-loop-matrix-index/31508)

<div class="topic-metadata">

**Author:** [@niuuin](https://discourse.processing.org/u/niuuin)\
**Replies:** 14\
**Last updated:** [August 4, 2021, 12:52pm UTC](https://discourse.processing.org/t/for-loop-matrix-index/31508 "2021-08-04T12:52:19Z")

</div>

int total; float itemSize; void setup() { size(800, 800); pixelDensity(2); smooth(); rectMode(CENTER); total = 4; itemSize = width/total; } void draw() { clear(); for (int i = 0; i \< sq(total); i ++) …

---

## [Trying to make my own version of the "quick draw" game to build a library and teach an AI as a BEGINNER](https://discourse.processing.org/t/trying-to-make-my-own-version-of-the-quick-draw-game-to-build-a-library-and-teach-an-ai-as-a-beginner/30518)

<div class="topic-metadata">

**Author:** [@anntie](https://discourse.processing.org/u/anntie)\
**Replies:** 36\
**Last updated:** [August 2, 2021, 5:29pm UTC](https://discourse.processing.org/t/trying-to-make-my-own-version-of-the-quick-draw-game-to-build-a-library-and-teach-an-ai-as-a-beginner/30518 "2021-08-02T17:29:06Z")

</div>

Hello! I am working on a design project about emotive writing. I would like to teach an AI to detect “emotions” from simple hand-drawn lines, and maybe use a GAN to generate lines according to specified emotional categor…

---

## [Union type in Processing programming](https://discourse.processing.org/t/union-type-in-processing-programming/31534)

<div class="topic-metadata">

**Author:** [@MJAhmadi](https://discourse.processing.org/u/MJAhmadi)\
**Replies:** 1\
**Last updated:** [August 1, 2021, 2:28pm UTC](https://discourse.processing.org/t/union-type-in-processing-programming/31534 "2021-08-01T14:28:01Z")

</div>

hi , below code is for c++ typedef union{ float number; uint8\_t bytes\[4\]; } FLOATUNION\_t; FLOATUNION\_t myValue; how can i write it in processing ?

---

## [Using P3D - core dumps error](https://discourse.processing.org/t/using-p3d-core-dumps-error/31486)

<div class="topic-metadata">

**Author:** [@garrettlynch](https://discourse.processing.org/u/garrettlynch)\
**Replies:** 0\
**Last updated:** [July 29, 2021, 4:26pm UTC](https://discourse.processing.org/t/using-p3d-core-dumps-error/31486 "2021-07-29T16:26:12Z")

</div>

Hi Having problems running a very simple sketch that sets size(2000, 2000, P3D); in settings(). The error is as follows: # A fatal error has been detected by the Java Runtime Environment: # # SIGILL (0x4) at pc=0x0000…

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

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