# Coding Questions

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

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

**Page:** 30

---

## [Infinite scrolling?!](https://discourse.processing.org/t/infinite-scrolling/34028)

<div class="topic-metadata">

**Author:** [@doordewar](https://discourse.processing.org/u/doordewar)\
**Replies:** 7\
**Last updated:** [May 18, 2022, 10:58am UTC](https://discourse.processing.org/t/infinite-scrolling/34028 "2022-05-18T10:58:58Z")

</div>

Hi all, I am trying to create infinite scrolling of images (only vertically), basically like any infinite scroll (social) media platform. What would be the way to go about this? I have tried preloading a large amount of…

---

## [How to add a new item in a arraylist when this class is defined by myself?](https://discourse.processing.org/t/how-to-add-a-new-item-in-a-arraylist-when-this-class-is-defined-by-myself/36944)

<div class="topic-metadata">

**Author:** [@Lee027](https://discourse.processing.org/u/Lee027)\
**Replies:** 6\
**Last updated:** [May 19, 2022, 2:06pm UTC](https://discourse.processing.org/t/how-to-add-a-new-item-in-a-arraylist-when-this-class-is-defined-by-myself/36944 "2022-05-19T14:06:53Z")

</div>

I defined a class named (drop) to represent a moving cloud with rain. And then I created an array uninitialized named (drops\[\]) to represent a list will increase automatically with ‘for loop’ in a table. But when using …

---

## [Beziers with noise](https://discourse.processing.org/t/beziers-with-noise/36949)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 7\
**Last updated:** [May 19, 2022, 12:19am UTC](https://discourse.processing.org/t/beziers-with-noise/36949 "2022-05-19T00:19:08Z")

</div>

Hi there, I am doing a loop with bezier curves and I am trying to make small variations between them, as you can see on the picture. I have read that noise function is the best way to make these kind of variations but I…

---

## [Rotate() a Texture in a PShape don't work anymore in P4](https://discourse.processing.org/t/rotate-a-texture-in-a-pshape-dont-work-anymore-in-p4/36941)

<div class="topic-metadata">

**Author:** [@matheplica](https://discourse.processing.org/u/matheplica)\
**Replies:** 0\
**Last updated:** [May 18, 2022, 12:45pm UTC](https://discourse.processing.org/t/rotate-a-texture-in-a-pshape-dont-work-anymore-in-p4/36941 "2022-05-18T12:45:07Z")

</div>

Hi, I’m trying to use this code in P4 to rotate a Texture in a PShape void adaptTexture() { uvtr.reset(); uvtr.translate(0.5, 0.5); uvtr.rotate(rotText); uvtr.translate(-0.5, -0.5); …

---

## [How to move an object across a game board. Multiple Objects](https://discourse.processing.org/t/how-to-move-an-object-across-a-game-board-multiple-objects/36926)

<div class="topic-metadata">

**Author:** [@Gray](https://discourse.processing.org/u/Gray)\
**Replies:** 0\
**Last updated:** [May 17, 2022, 4:57pm UTC](https://discourse.processing.org/t/how-to-move-an-object-across-a-game-board-multiple-objects/36926 "2022-05-17T16:57:30Z")

</div>

Hello! I am an extreme beginner in the field of P5.JS. I am way more knowledgeable in Java which will be apparent in my broken code. I have attempted a multitude of Java approaches to cycling through objects of the same …

---

## [The output is missing when button is pressed](https://discourse.processing.org/t/the-output-is-missing-when-button-is-pressed/36917)

<div class="topic-metadata">

**Author:** [@jjjjjjj](https://discourse.processing.org/u/jjjjjjj)\
**Replies:** 2\
**Last updated:** [May 17, 2022, 4:23pm UTC](https://discourse.processing.org/t/the-output-is-missing-when-button-is-pressed/36917 "2022-05-17T16:23:36Z")

</div>

Hi, I’m doing an assignment which I have to create a game and I’ve attempted to create a functioning menu. I coded buttons that navigate to different modes(?) when clicked using class (to create button) and switch (to go…

---

## [Is there an easy way to get an image from a section of an image?](https://discourse.processing.org/t/is-there-an-easy-way-to-get-an-image-from-a-section-of-an-image/36902)

<div class="topic-metadata">

**Author:** [@AntiViral\_Builder](https://discourse.processing.org/u/AntiViral_Builder)\
**Replies:** 3\
**Last updated:** [May 15, 2022, 9:27pm UTC](https://discourse.processing.org/t/is-there-an-easy-way-to-get-an-image-from-a-section-of-an-image/36902 "2022-05-15T21:27:43Z")

</div>

I would like to be able to do this quickly and not have to go through each pixel to transfer them.

---

## [How to pause part of a draw loop](https://discourse.processing.org/t/how-to-pause-part-of-a-draw-loop/36891)

<div class="topic-metadata">

**Author:** [@Blushdow7](https://discourse.processing.org/u/Blushdow7)\
**Replies:** 3\
**Last updated:** [May 15, 2022, 9:09pm UTC](https://discourse.processing.org/t/how-to-pause-part-of-a-draw-loop/36891 "2022-05-15T21:09:14Z")

</div>

I’m trying to make my character be able to crouch so i have void draw () background(0) imageMode(CENTER); image(box.image1,0,0); void keyPressed() { if (key == ‘s’) { image(box.image3, box.position.x, box.positio…

---

## [Create 500 PGraphics at the same time](https://discourse.processing.org/t/create-500-pgraphics-at-the-same-time/36900)

<div class="topic-metadata">

**Author:** [@Rag](https://discourse.processing.org/u/Rag)\
**Replies:** 5\
**Last updated:** [May 15, 2022, 6:55pm UTC](https://discourse.processing.org/t/create-500-pgraphics-at-the-same-time/36900 "2022-05-15T18:55:11Z")

</div>

I am trying to optimize a part of my code that creates 500 PGraphics. Is there a way to creates them all at the same time ? final int child\_count = 5; final int min\_size = 5; final int max\_size = 300; final int position…

---

## [Restricted rotation next to a wall](https://discourse.processing.org/t/restricted-rotation-next-to-a-wall/36687)

<div class="topic-metadata">

**Author:** [@Divitiacus](https://discourse.processing.org/u/Divitiacus)\
**Replies:** 6\
**Last updated:** [May 12, 2022, 8:30pm UTC](https://discourse.processing.org/t/restricted-rotation-next-to-a-wall/36687 "2022-05-12T20:30:24Z")

</div>

Currently I am trying to find a way to calculate restricted random rotation close to a wall/two walls/three walls. What I do, and it works, is to find the sector of the rotation circle, which is excluded, by trigonometr…

---

## [Trying to check if a font can display certain glyphs](https://discourse.processing.org/t/trying-to-check-if-a-font-can-display-certain-glyphs/36795)

<div class="topic-metadata">

**Author:** [@disuye](https://discourse.processing.org/u/disuye)\
**Replies:** 3\
**Last updated:** [May 12, 2022, 7:58pm UTC](https://discourse.processing.org/t/trying-to-check-if-a-font-can-display-certain-glyphs/36795 "2022-05-12T19:58:30Z")

</div>

Regarding the code below, I’m having difficulties using font.canDisplayUpTo() – I think it’s an issue with the URL being passed to Font font =… ? The fonts are all fine, so it’s something to do with how Font is being fed…

---

## [Why is the program ignoring my second for- loop?](https://discourse.processing.org/t/why-is-the-program-ignoring-my-second-for-loop/36819)

<div class="topic-metadata">

**Author:** [@Katharina](https://discourse.processing.org/u/Katharina)\
**Replies:** 3\
**Last updated:** [May 11, 2022, 2:42pm UTC](https://discourse.processing.org/t/why-is-the-program-ignoring-my-second-for-loop/36819 "2022-05-11T14:42:23Z")

</div>

Please help me, im a beginner in Processing. Before I’ll tell my problem I’ll twll you about the programm so u wont get confused. I want to create 2 arrows (left and right) they need to be next to eachother. I need 4 r…

---

## [Aspect ratio screen resizing](https://discourse.processing.org/t/aspect-ratio-screen-resizing/19538)

<div class="topic-metadata">

**Author:** [@s6277](https://discourse.processing.org/u/s6277)\
**Replies:** 2\
**Last updated:** [May 9, 2022, 7:09pm UTC](https://discourse.processing.org/t/aspect-ratio-screen-resizing/19538 "2022-05-09T19:09:48Z")

</div>

Hey, I’m really struggling aspect ratio on processing, i want to be able to resize the screen and when i resize it the object inside is also resized according to the screen. I have currently used: surface.setResizable(t…

---

## [Trying to convert this example into an OOP](https://discourse.processing.org/t/trying-to-convert-this-example-into-an-oop/36776)

<div class="topic-metadata">

**Author:** [@Whell](https://discourse.processing.org/u/Whell)\
**Replies:** 2\
**Last updated:** [May 9, 2022, 12:26pm UTC](https://discourse.processing.org/t/trying-to-convert-this-example-into-an-oop/36776 "2022-05-09T12:26:53Z")

</div>

Hi, i’m trying to remake this example of Nature of Code (code 1) but instead of drawing in the draw loop, i’m trying to make it as an Object Oriented Program (code 2), however, the behavior of the object is way off. I ki…

---

## [Cannot Export DXF from PWindow?](https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767)

<div class="topic-metadata">

**Author:** [@dimpapadop](https://discourse.processing.org/u/dimpapadop)\
**Replies:** 3\
**Last updated:** [May 8, 2022, 12:43pm UTC](https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767 "2022-05-08T12:43:53Z")

</div>

Hallo. I have the following problem. In a second window of my sketch that i use for previewing in 3d, i have a set of pshapes drawn in 3d space, but i cannot get them to be exported as dxf. Actually, nothing is exporte…

---

## [How to manipulate and save data in shaderbuffers](https://discourse.processing.org/t/how-to-manipulate-and-save-data-in-shaderbuffers/36766)

<div class="topic-metadata">

**Author:** [@Amirk](https://discourse.processing.org/u/Amirk)\
**Replies:** 0\
**Last updated:** [May 8, 2022, 5:42am UTC](https://discourse.processing.org/t/how-to-manipulate-and-save-data-in-shaderbuffers/36766 "2022-05-08T05:42:04Z")

</div>

I can access bufferdata with a shader, and use it within the shader code, but how could I save updated data into back the same buffer with the shader? Im trying to buld some Lattice Boltzmann simulations in this manner: …

---

## [Can Processing Objects/Classes be used in pure Java Graphics2D environment? (with/without extending the Applet)](https://discourse.processing.org/t/can-processing-objects-classes-be-used-in-pure-java-graphics2d-environment-with-without-extending-the-applet/36730)

<div class="topic-metadata">

**Author:** [@istinn](https://discourse.processing.org/u/istinn)\
**Replies:** 4\
**Last updated:** [May 7, 2022, 5:39pm UTC](https://discourse.processing.org/t/can-processing-objects-classes-be-used-in-pure-java-graphics2d-environment-with-without-extending-the-applet/36730 "2022-05-07T17:39:51Z")

</div>

Hi, are there any examples that use (import) processing classes in combination with the classic pure Graphics2D environment outside Processing? I mean not just extending the Processing Applet (the new window), but exten…

---

## ["the function substring(int) does not exist"](https://discourse.processing.org/t/the-function-substring-int-does-not-exist/36757)

<div class="topic-metadata">

**Author:** [@AmberGoop](https://discourse.processing.org/u/AmberGoop)\
**Replies:** 3\
**Last updated:** [May 7, 2022, 10:50am UTC](https://discourse.processing.org/t/the-function-substring-int-does-not-exist/36757 "2022-05-07T10:50:41Z")

</div>

i’m having a peculiar issue here - and it’s in the title. i’m trying to use substring() to cut the first chunk of a long string off, but processing (4.0b2) is telling me that “The function substring(int) does not exist.…

---

## [Drawing many image thumbnails in expanding circle](https://discourse.processing.org/t/drawing-many-image-thumbnails-in-expanding-circle/36718)

<div class="topic-metadata">

**Author:** [@sleepythief](https://discourse.processing.org/u/sleepythief)\
**Replies:** 4\
**Last updated:** [May 5, 2022, 7:03pm UTC](https://discourse.processing.org/t/drawing-many-image-thumbnails-in-expanding-circle/36718 "2022-05-05T19:03:57Z")

</div>

I have loaded array of PImages (2,000 20x20 jpgs) PImage\[\] images; That I wish to arrange in a circle manner from the center of the display. I can do this easily in a grid with a column, row nested for loop, however m…

---

## [How do I slowly layer photos to appear on top of eachother?](https://discourse.processing.org/t/how-do-i-slowly-layer-photos-to-appear-on-top-of-eachother/36698)

<div class="topic-metadata">

**Author:** [@JennyMcCreadie](https://discourse.processing.org/u/JennyMcCreadie)\
**Replies:** 6\
**Last updated:** [May 4, 2022, 4:41pm UTC](https://discourse.processing.org/t/how-do-i-slowly-layer-photos-to-appear-on-top-of-eachother/36698 "2022-05-04T16:41:23Z")

</div>

Hello! I am trying to work out if there is a simple way to gradually fade photos on top of eachother? Basically, to show one image, which slowly fades in to the next, which slowly fades in to the next, etc. I’ve been p…

---

## [Box just going off screen and then disappears. Please help](https://discourse.processing.org/t/box-just-going-off-screen-and-then-disappears-please-help/36697)

<div class="topic-metadata">

**Author:** [@king\_B99](https://discourse.processing.org/u/king_B99)\
**Replies:** 1\
**Last updated:** [May 3, 2022, 6:46pm UTC](https://discourse.processing.org/t/box-just-going-off-screen-and-then-disappears-please-help/36697 "2022-05-03T18:46:47Z")

</div>

So i have a box that goes across the screen and is is supposed to loop but it just does it once Broken Partif (boxX+10 ==(width)) { boxX=width-width+1; } boxX = boxX+10; rect(boxX, boxY, 50, 50); } Full Codeint car…

---

## [Modify elements in a for loop separately using PGraphics](https://discourse.processing.org/t/modify-elements-in-a-for-loop-separately-using-pgraphics/36636)

<div class="topic-metadata">

**Author:** [@belen.s](https://discourse.processing.org/u/belen.s)\
**Replies:** 1\
**Last updated:** [May 3, 2022, 10:57am UTC](https://discourse.processing.org/t/modify-elements-in-a-for-loop-separately-using-pgraphics/36636 "2022-05-03T10:57:15Z")

</div>

Hello!! I have made a figure with a for loop inside a class, and I want to make each element made in the loop have different colors. Here is my code. Any help would be great… float x; float y; Madre c; //MadreLider d; …

---

## [Working with 48bit image formats. How to load, process, save?](https://discourse.processing.org/t/working-with-48bit-image-formats-how-to-load-process-save/36652)

<div class="topic-metadata">

**Author:** [@phillipstearns](https://discourse.processing.org/u/phillipstearns)\
**Replies:** 2\
**Last updated:** [April 30, 2022, 2:21am UTC](https://discourse.processing.org/t/working-with-48bit-image-formats-how-to-load-process-save/36652 "2022-04-30T02:21:46Z")

</div>

I’m working on a project where I’ve been asked to work with 48bit (16bits per channel RGB) .PNG files. I’ll need to open, read and manipulate pixel data, and save to 48bit .PNG. Is this possible with Processing 4?

---

## [I have several issues with my else if and if structures](https://discourse.processing.org/t/i-have-several-issues-with-my-else-if-and-if-structures/36650)

<div class="topic-metadata">

**Author:** [@nalk](https://discourse.processing.org/u/nalk)\
**Replies:** 2\
**Last updated:** [April 29, 2022, 11:06pm UTC](https://discourse.processing.org/t/i-have-several-issues-with-my-else-if-and-if-structures/36650 "2022-04-29T23:06:17Z")

</div>

My mousePressed if else structure seems to be skipping some “estado” and not working at all int estado = 0; // Establezco las imagenes que van a usarse. PImage img0, img1, img2, img3, img4, img5, img6; // Establezco …

---

## [Use Mouse-funktions in classes](https://discourse.processing.org/t/use-mouse-funktions-in-classes/29673)

<div class="topic-metadata">

**Author:** [@TimeLex](https://discourse.processing.org/u/TimeLex)\
**Replies:** 7\
**Last updated:** [April 29, 2022, 5:09pm UTC](https://discourse.processing.org/t/use-mouse-funktions-in-classes/29673 "2022-04-29T17:09:11Z")

</div>

I want to write a class that is able to use Mouse-funktions like mousePressed() but the funktion is not triggered in a class: myClass c; void setup() { size(500, 500); c = new myClass(); } void draw() { c.upd…

---

## [Creating a static variable from a non-static method (like color())](https://discourse.processing.org/t/creating-a-static-variable-from-a-non-static-method-like-color/36641)

<div class="topic-metadata">

**Author:** [@GuyInFridge](https://discourse.processing.org/u/GuyInFridge)\
**Replies:** 6\
**Last updated:** [April 29, 2022, 4:02pm UTC](https://discourse.processing.org/t/creating-a-static-variable-from-a-non-static-method-like-color/36641 "2022-04-29T16:02:15Z")

</div>

I would like to create a class which has a static field “c\_DEFAULT” that stores a default color for all objects of that class. The problem is that I can’t do the following: static final color c\_DEFAULT = color(175); //…

---

## [Is it possible to 'offset' an object, e.g concentric circles?](https://discourse.processing.org/t/is-it-possible-to-offset-an-object-e-g-concentric-circles/36586)

<div class="topic-metadata">

**Author:** [@GoodJuJu](https://discourse.processing.org/u/GoodJuJu)\
**Replies:** 2\
**Last updated:** [April 29, 2022, 1:18pm UTC](https://discourse.processing.org/t/is-it-possible-to-offset-an-object-e-g-concentric-circles/36586 "2022-04-29T13:18:49Z")

</div>

In AutoCAD, there is a command to ‘offset’ an object. You select the object (line, circle, rectangle, arc etc.), specify either a positive or a negative value and the object will be ‘offset’ according to the entered val…

---

## [Function KeyTyped () and draw function](https://discourse.processing.org/t/function-keytyped-and-draw-function/36633)

<div class="topic-metadata">

**Author:** [@JessJess](https://discourse.processing.org/u/JessJess)\
**Replies:** 1\
**Last updated:** [April 28, 2022, 7:16pm UTC](https://discourse.processing.org/t/function-keytyped-and-draw-function/36633 "2022-04-28T19:16:17Z")

</div>

Hi, I want to create a code where when I click a key on the keyboard it will play music and draw a rectangle. I have managed to add music using the keyTyped() function but I am not sure how to add a rectangle to the canv…

---

## [Circles with polar coordinates](https://discourse.processing.org/t/circles-with-polar-coordinates/36593)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 13\
**Last updated:** [April 28, 2022, 8:51am UTC](https://discourse.processing.org/t/circles-with-polar-coordinates/36593 "2022-04-28T08:51:40Z")

</div>

Hi there! I am really interested on Katharina Brunner’s work with circles made with thousand of points. I have read that she made them using a polar coordinate system. I think that she has a package to create them with R…

---

## [Parsing points from a text file](https://discourse.processing.org/t/parsing-points-from-a-text-file/36611)

<div class="topic-metadata">

**Author:** [@Aaron\_Barber272](https://discourse.processing.org/u/Aaron_Barber272)\
**Replies:** 1\
**Last updated:** [April 27, 2022, 12:54am UTC](https://discourse.processing.org/t/parsing-points-from-a-text-file/36611 "2022-04-27T00:54:22Z")

</div>

PVector\[\] globe; float x = 0; float y = 0; float z = 0; import peasy.\*; PeasyCam cam; void setup() { size(600, 600, P3D); cam = new PeasyCam(this, 500); globe = new PVector\[30\]; stroke(255); lights(); } void…

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

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