# Coding Questions

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

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

**Page:** 128

---

## [Applying Class to each character in a string](https://discourse.processing.org/t/applying-class-to-each-character-in-a-string/13870)

<div class="topic-metadata">

**Author:** [@tylerowens](https://discourse.processing.org/u/tylerowens)\
**Replies:** 7\
**Last updated:** [September 8, 2019, 10:13am UTC](https://discourse.processing.org/t/applying-class-to-each-character-in-a-string/13870 "2019-09-08T10:13:32Z")

</div>

Hello all, I am going to try my best to describe what I am trying to make so I can hopefully receive some help. I am trying to make each character in a string accelerate towards the mouse. With the code I have currently…

---

## [Piston effect in Processing simulation](https://discourse.processing.org/t/piston-effect-in-processing-simulation/13867)

<div class="topic-metadata">

**Author:** [@harvious](https://discourse.processing.org/u/harvious)\
**Replies:** 1\
**Last updated:** [September 7, 2019, 2:38pm UTC](https://discourse.processing.org/t/piston-effect-in-processing-simulation/13867 "2019-09-07T14:38:17Z")

</div>

0 I am trying to set up a simulation of a 2D box containing a number of particles (circles of radius r) colliding elastically with each other and the wall. I then tried to add in a piston (a line object with some stroke…

---

## [Is there a way to make random grids/layouts in Processing?](https://discourse.processing.org/t/is-there-a-way-to-make-random-grids-layouts-in-processing/13854)

<div class="topic-metadata">

**Author:** [@jb99](https://discourse.processing.org/u/jb99)\
**Replies:** 10\
**Last updated:** [September 7, 2019, 5:55pm UTC](https://discourse.processing.org/t/is-there-a-way-to-make-random-grids-layouts-in-processing/13854 "2019-09-07T17:55:37Z")

</div>

Hi everyone, I’m a visual designer and I’m new to processing. I would like to know if there are any possibilities in Processing to create random aesthetic grids/layouts for editorial projects let’s say that are very sim…

---

## [How to snap mouse to a shape/coordinate?](https://discourse.processing.org/t/how-to-snap-mouse-to-a-shape-coordinate/13414)

<div class="topic-metadata">

**Author:** [@NadeW](https://discourse.processing.org/u/NadeW)\
**Replies:** 8\
**Last updated:** [August 18, 2019, 2:48pm UTC](https://discourse.processing.org/t/how-to-snap-mouse-to-a-shape-coordinate/13414 "2019-08-18T14:48:45Z")

</div>

Hello my idea is to snap the mouse cursor to intersections on a grid when the user approaches them (this will center the mouse pointer to that cross on the grid). I did some digging but I haven’t found anything that can …

---

## [Getting User input](https://discourse.processing.org/t/getting-user-input/1670)

<div class="topic-metadata">

**Author:** [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Replies:** 16\
**Last updated:** [September 6, 2019, 12:46pm UTC](https://discourse.processing.org/t/getting-user-input/1670 "2019-09-06T12:46:42Z")

</div>

Java Proccessing OK, I’ve watched several youtube shows of getting the user’s input. Even though I didn’t like the way they did it I tried it since I have no other idea of how to do it. So in the game I’m making my high…

---

## [Transform shapes so part of wall appears to be decaying](https://discourse.processing.org/t/transform-shapes-so-part-of-wall-appears-to-be-decaying/13742)

<div class="topic-metadata">

**Author:** [@helpMe](https://discourse.processing.org/u/helpMe)\
**Replies:** 8\
**Last updated:** [September 5, 2019, 9:16am UTC](https://discourse.processing.org/t/transform-shapes-so-part-of-wall-appears-to-be-decaying/13742 "2019-09-05T09:16:16Z")

</div>

Hi, I’m working in a project. I did some code, but which is not done. I’m very new in processing. I don’t understand properly how everything works. I’ll share the project idea and code below. Can someone help me with the…

---

## [Can't use image with SVG library](https://discourse.processing.org/t/cant-use-image-with-svg-library/13795)

<div class="topic-metadata">

**Author:** [@Sahan](https://discourse.processing.org/u/Sahan)\
**Replies:** 0\
**Last updated:** [September 4, 2019, 11:03am UTC](https://discourse.processing.org/t/cant-use-image-with-svg-library/13795 "2019-09-04T11:03:51Z")

</div>

hello I am using processing p3, I want to convert a bitmap image to SVG. i edited one of the programs in SVG libraries of Processing with image() function, it throws an error. as I am new to programming, Pl suggest me …

---

## [YAML file editing](https://discourse.processing.org/t/yaml-file-editing/13602)

<div class="topic-metadata">

**Author:** [@RockyHawk](https://discourse.processing.org/u/RockyHawk)\
**Replies:** 2\
**Last updated:** [August 26, 2019, 2:22pm UTC](https://discourse.processing.org/t/yaml-file-editing/13602 "2019-08-26T14:22:22Z")

</div>

I was wondering if there was a way to edit a YAML file and save the edited version… So it would be something like this maybe: File yaml = new File(System.getProperty("user.home") + "/Desktop/\*.\*"); selectInput("Choose …

---

## [Shooting moving circles](https://discourse.processing.org/t/shooting-moving-circles/13791)

<div class="topic-metadata">

**Author:** [@sbiju72](https://discourse.processing.org/u/sbiju72)\
**Replies:** 2\
**Last updated:** [September 4, 2019, 12:02pm UTC](https://discourse.processing.org/t/shooting-moving-circles/13791 "2019-09-04T12:02:17Z")

</div>

I’m trying to shoot a moving ball. Most of it works (ball moves, hit is detected). Except the the movement of bullet. I can’t get it moving. void setup(){ size(1000,800); } Projectile bullet = new Projectile(); Enem…

---

## [Left hand side of the argument](https://discourse.processing.org/t/left-hand-side-of-the-argument/13771)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 1\
**Last updated:** [September 3, 2019, 2:58am UTC](https://discourse.processing.org/t/left-hand-side-of-the-argument/13771 "2019-09-03T02:58:03Z")

</div>

Converting code from P5.js. In the original code I had an array which can be flexible in p5 which I used to store the location of the Objects I’m working with, and In my function I would call the location in the array an…

---

## [Possible at all? Create path on image, generate cutting boxes, separate each box](https://discourse.processing.org/t/possible-at-all-create-path-on-image-generate-cutting-boxes-separate-each-box/13756)

<div class="topic-metadata">

**Author:** [@damomp](https://discourse.processing.org/u/damomp)\
**Replies:** 10\
**Last updated:** [September 3, 2019, 12:04am UTC](https://discourse.processing.org/t/possible-at-all-create-path-on-image-generate-cutting-boxes-separate-each-box/13756 "2019-09-03T00:04:35Z")

</div>

Dear all, just getting started with processing and wondering if this is possible within processing? I haven’t succeeded doing this in photoshop. I need to dissolve an image into smaller party while each part should be…

---

## [Request for SVG Gradient file](https://discourse.processing.org/t/request-for-svg-gradient-file/12116)

<div class="topic-metadata">

**Author:** [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Replies:** 4\
**Last updated:** [September 2, 2019, 6:02pm UTC](https://discourse.processing.org/t/request-for-svg-gradient-file/12116 "2019-09-02T18:02:55Z")

</div>

Could someone provide me a svg with a gradient that works in processing? I wan’t to see if I can make processing support svg gradients from svg’s exported from affinity designer, but it would be really helpfull to have …

---

## [Shader as texture for primitive](https://discourse.processing.org/t/shader-as-texture-for-primitive/13680)

<div class="topic-metadata">

**Author:** [@lnp](https://discourse.processing.org/u/lnp)\
**Replies:** 13\
**Last updated:** [August 29, 2019, 9:18pm UTC](https://discourse.processing.org/t/shader-as-texture-for-primitive/13680 "2019-08-29T21:18:26Z")

</div>

Is it possible to use a shader as a texture on a 3d primitive? When I invoke shader the effect is to render the sphere as a flat 2d object with the shader as a fill rather than a texture. I thought I could call texture(…

---

## [PShape texture only applies colour not text?](https://discourse.processing.org/t/pshape-texture-only-applies-colour-not-text/13596)

<div class="topic-metadata">

**Author:** [@michthom](https://discourse.processing.org/u/michthom)\
**Replies:** 12\
**Last updated:** [August 31, 2019, 7:52pm UTC](https://discourse.processing.org/t/pshape-texture-only-applies-colour-not-text/13596 "2019-08-31T19:52:12Z")

</div>

Hi folks I’m trying to create a PShape - a rounded rectangle, with a texture consisting of a background colour and some text overlaid. There may be simpler ways, but this is for a project where I’ll be displaying hundre…

---

## [How do I switch between fullscreen and windowed during the sketch](https://discourse.processing.org/t/how-do-i-switch-between-fullscreen-and-windowed-during-the-sketch/13726)

<div class="topic-metadata">

**Author:** [@Lachieblue](https://discourse.processing.org/u/Lachieblue)\
**Replies:** 1\
**Last updated:** [August 31, 2019, 6:41pm UTC](https://discourse.processing.org/t/how-do-i-switch-between-fullscreen-and-windowed-during-the-sketch/13726 "2019-08-31T18:41:33Z")

</div>

So as the title says, I want to create a button or something that I can click during a sketch to resize the window from fullscreen to different windowed resolutions like in a game. I’ve experimented with surface.setSize…

---

## [Getting really bad lag with a function](https://discourse.processing.org/t/getting-really-bad-lag-with-a-function/13725)

<div class="topic-metadata">

**Author:** [@lax](https://discourse.processing.org/u/lax)\
**Replies:** 4\
**Last updated:** [August 31, 2019, 6:24pm UTC](https://discourse.processing.org/t/getting-really-bad-lag-with-a-function/13725 "2019-08-31T18:24:33Z")

</div>

Hi, I have this function which i run on every pixel, which causes the fps to drop to around 1 fps: PVector kaleido(PVector uv) { float th = atan2(uv.y, uv.x); float r = uv.magSq(); th = sin(th \* 6.283f / 0.8975979…

---

## [Help me understand this cool/short code on OpenProcessing](https://discourse.processing.org/t/help-me-understand-this-cool-short-code-on-openprocessing/13721)

<div class="topic-metadata">

**Author:** [@sorenkirk](https://discourse.processing.org/u/sorenkirk)\
**Replies:** 0\
**Last updated:** [August 31, 2019, 1:12pm UTC](https://discourse.processing.org/t/help-me-understand-this-cool-short-code-on-openprocessing/13721 "2019-08-31T13:12:35Z")

</div>

I found the following code on Open Processing. https://www.openprocessing.org/sketch/374455 Would somebody help me understand the Particle class? In particular, what is the math going on in the update function? class …

---

## [How to find number of displays](https://discourse.processing.org/t/how-to-find-number-of-displays/13037)

<div class="topic-metadata">

**Author:** [@jtk](https://discourse.processing.org/u/jtk)\
**Replies:** 3\
**Last updated:** [August 31, 2019, 11:35am UTC](https://discourse.processing.org/t/how-to-find-number-of-displays/13037 "2019-08-31T11:35:28Z")

</div>

Is there a way to find out how many displays are available to my Processing program? I would like my sketch to start in fullScreen on display 2 if it is connected, otherwise display 1. Currently, I’m using fullScreen(2…

---

## [Trouble with the bouncing ball example from the NoC book](https://discourse.processing.org/t/trouble-with-the-bouncing-ball-example-from-the-noc-book/13705)

<div class="topic-metadata">

**Author:** [@cyml](https://discourse.processing.org/u/cyml)\
**Replies:** 8\
**Last updated:** [August 31, 2019, 9:50am UTC](https://discourse.processing.org/t/trouble-with-the-bouncing-ball-example-from-the-noc-book/13705 "2019-08-31T09:50:30Z")

</div>

on my first embark of the first example in The Nature of Code, Processing is telling me Missing right parenthesis “)” and I compared my code to Daniel’s sample code… and I couldn’t figure out why. Can someone help me…

---

## [Learning curve in Generative Art](https://discourse.processing.org/t/learning-curve-in-generative-art/13612)

<div class="topic-metadata">

**Author:** [@Marinus](https://discourse.processing.org/u/Marinus)\
**Replies:** 12\
**Last updated:** [August 31, 2019, 9:10am UTC](https://discourse.processing.org/t/learning-curve-in-generative-art/13612 "2019-08-31T09:10:26Z")

</div>

Hi all, first post here. A little background info: One week ago I started to learn how to code in Processing. I’m not familiar with creating code, only with altering work of others. I’ve worked in python, java, javascri…

---

## [Noise edge detection](https://discourse.processing.org/t/noise-edge-detection/13367)

<div class="topic-metadata">

**Author:** [@TimoL](https://discourse.processing.org/u/TimoL)\
**Replies:** 4\
**Last updated:** [August 30, 2019, 6:09pm UTC](https://discourse.processing.org/t/noise-edge-detection/13367 "2019-08-30T18:09:12Z")

</div>

Hi all! Im struggling to put into words what I need help with. Im not sure how best to use noise to effect a grid of shapes. I’ve included my code which should help clarify… Basically I have a grid of rectangles and …

---

## [Mapping degrees excluding 360.0](https://discourse.processing.org/t/mapping-degrees-excluding-360-0/13691)

<div class="topic-metadata">

**Author:** [@ddownn](https://discourse.processing.org/u/ddownn)\
**Replies:** 2\
**Last updated:** [August 29, 2019, 6:29pm UTC](https://discourse.processing.org/t/mapping-degrees-excluding-360-0/13691 "2019-08-29T18:29:22Z")

</div>

I’ve been working on a control that behaves like an encoder wheel that is turned with the mouse and outputs the current angle of rotation. I’m having trouble figuring out how to get it to output 0 through 360 but forcin…

---

## [Perlin noise problem with higher numbers](https://discourse.processing.org/t/perlin-noise-problem-with-higher-numbers/13672)

<div class="topic-metadata">

**Author:** [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Replies:** 9\
**Last updated:** [August 29, 2019, 4:35pm UTC](https://discourse.processing.org/t/perlin-noise-problem-with-higher-numbers/13672 "2019-08-29T16:35:14Z")

</div>

Hello i try to increase one of pos of 2D perlin noise generator and its going wrong. Its draws lines not “clouds” as before with lower number… Is the some MAXIMUM number of perlin noise posX and posY ? Here is the cod…

---

## [CNN not working](https://discourse.processing.org/t/cnn-not-working/10190)

<div class="topic-metadata">

**Author:** [@Odermonicon](https://discourse.processing.org/u/Odermonicon)\
**Replies:** 3\
**Last updated:** [August 29, 2019, 9:23am UTC](https://discourse.processing.org/t/cnn-not-working/10190 "2019-08-29T09:23:50Z")

</div>

Literally no idea why it doesn’t work plz help CodePImage ini; PImage reo; String\[\] log = {}; int\[\]\[\] con = { {-1,0,1}, {-1,0,1}, {-1,0,1} }; int cropsize = 10; void setup() { ini = loadImage("img.png"); …

---

## [Randomizing shot](https://discourse.processing.org/t/randomizing-shot/13679)

<div class="topic-metadata">

**Author:** [@Not\_River](https://discourse.processing.org/u/Not_River)\
**Replies:** 1\
**Last updated:** [August 29, 2019, 8:49am UTC](https://discourse.processing.org/t/randomizing-shot/13679 "2019-08-29T08:49:25Z")

</div>

I’m trying to design an enemy that shoots multiple shots in random directions, I have an Idea of what I want to do, but I don’t know where to put it. What I want to do is make the xSpeed of the shot randomize between 0 a…

---

## [Trim primitive shapes](https://discourse.processing.org/t/trim-primitive-shapes/13131)

<div class="topic-metadata">

**Author:** [@TimoL](https://discourse.processing.org/u/TimoL)\
**Replies:** 20\
**Last updated:** [August 29, 2019, 8:25am UTC](https://discourse.processing.org/t/trim-primitive-shapes/13131 "2019-08-29T08:25:10Z")

</div>

Hi there, need a little help figuring this one out… Ive had a search but havent found any topics that I think would help mw… Basically Im trying to mask some lines ive generated with a rectangle. I’ve seen a few post…

---

## [Justifying Text in PDF](https://discourse.processing.org/t/justifying-text-in-pdf/13564)

<div class="topic-metadata">

**Author:** [@grumo](https://discourse.processing.org/u/grumo)\
**Replies:** 4\
**Last updated:** [August 29, 2019, 5:09am UTC](https://discourse.processing.org/t/justifying-text-in-pdf/13564 "2019-08-29T05:09:03Z")

</div>

Ok. I fixed the code and I could run it. The script justifies the text in the box on screen BUT when I try to use it in the PDF mode it won’t work. If you run it you’ll see a justify-aligned box of text (finally!) but th…

---

## [It's possible to change between 2D and 3D while runing?](https://discourse.processing.org/t/its-possible-to-change-between-2d-and-3d-while-runing/13646)

<div class="topic-metadata">

**Author:** [@Waboqueox](https://discourse.processing.org/u/Waboqueox)\
**Replies:** 6\
**Last updated:** [August 28, 2019, 8:24pm UTC](https://discourse.processing.org/t/its-possible-to-change-between-2d-and-3d-while-runing/13646 "2019-08-28T20:24:58Z")

</div>

Hi there!! I want to switch between 2D and 3D pressing a button, don’t know if that’s possible, someone knows? I have my sketch running (processing 3, in android studio), and want to be able to change to 3D or go back …

---

## [Placing a texture on a pshape](https://discourse.processing.org/t/placing-a-texture-on-a-pshape/13561)

<div class="topic-metadata">

**Author:** [@sentfrom](https://discourse.processing.org/u/sentfrom)\
**Replies:** 5\
**Last updated:** [August 28, 2019, 5:22pm UTC](https://discourse.processing.org/t/placing-a-texture-on-a-pshape/13561 "2019-08-28T17:22:39Z")

</div>

Hello, I am making a game and I have a pshape planet with 360 vertices placed in a circle. PVector circ = new PVector(rad,0); tar = createShape(); tar.beginShape(); //loops 359 times to enable rotation in 1°…

---

## [Screen to PGraphic?](https://discourse.processing.org/t/screen-to-pgraphic/13622)

<div class="topic-metadata">

**Author:** [@aledante](https://discourse.processing.org/u/aledante)\
**Replies:** 9\
**Last updated:** [August 28, 2019, 4:21pm UTC](https://discourse.processing.org/t/screen-to-pgraphic/13622 "2019-08-28T16:21:20Z")

</div>

Hi!, Is there a way of directing all drawing instructions to a PGraphics? I’ve already write a program that draw something to the screen and now I want it in a PGraphic. I know that it is not difficult to write the code…

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

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