# Coding Questions

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

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

**Page:** 152

---

## [Driving Effect / Moving Dividing Line](https://discourse.processing.org/t/driving-effect-moving-dividing-line/8316)

<div class="topic-metadata">

**Author:** [@hexe43](https://discourse.processing.org/u/hexe43)\
**Replies:** 3\
**Last updated:** [February 12, 2019, 5:21pm UTC](https://discourse.processing.org/t/driving-effect-moving-dividing-line/8316 "2019-02-12T17:21:37Z")

</div>

Hi, I want to create a “car avoiding game”. To make it look like the cars are driving I want to make the dividing line move constantly from top to bottom in a loop. How is that possible? Hopefully, someone is able to hel…

---

## [Displaying HTML in JFrame](https://discourse.processing.org/t/displaying-html-in-jframe/8307)

<div class="topic-metadata">

**Author:** [@lmccandless](https://discourse.processing.org/u/lmccandless)\
**Replies:** 1\
**Last updated:** [February 12, 2019, 5:55am UTC](https://discourse.processing.org/t/displaying-html-in-jframe/8307 "2019-02-12T05:55:39Z")

</div>

I’d like to get some HTML from a page and display it instead of writing my own parsing and trying to display it all with text(); I’ve cobbled this together from examples I’ve found on the old forum and stackoverflow, b…

---

## [Projects a PVector onto camera](https://discourse.processing.org/t/projects-a-pvector-onto-camera/7908)

<div class="topic-metadata">

**Author:** [@vjjv](https://discourse.processing.org/u/vjjv)\
**Replies:** 3\
**Last updated:** [February 11, 2019, 9:31pm UTC](https://discourse.processing.org/t/projects-a-pvector-onto-camera/7908 "2019-02-11T21:31:07Z")

</div>

Hello! in three.js exist a function calls Projects (onto a camera): .project ( camera : Camera ) : this camera — camera to use in the projection. project: function ( camera ) { return this.applyMatrix4( camera.matri…

---

## [Why are if AND else being executed at the same time?](https://discourse.processing.org/t/why-are-if-and-else-being-executed-at-the-same-time/8246)

<div class="topic-metadata">

**Author:** [@Schred](https://discourse.processing.org/u/Schred)\
**Replies:** 3\
**Last updated:** [February 11, 2019, 6:49pm UTC](https://discourse.processing.org/t/why-are-if-and-else-being-executed-at-the-same-time/8246 "2019-02-11T18:49:11Z")

</div>

Hi! I’m working on a collision system at the moment and everything seemed to work fine (actually not but I want to solve all the other problems on my own lol :sweat\_smile:) but then I realised that a boolean in the code…

---

## [Newbie - connecting txt file to this code](https://discourse.processing.org/t/newbie-connecting-txt-file-to-this-code/8284)

<div class="topic-metadata">

**Author:** [@rezaniik](https://discourse.processing.org/u/rezaniik)\
**Replies:** 3\
**Last updated:** [February 11, 2019, 3:34pm UTC](https://discourse.processing.org/t/newbie-connecting-txt-file-to-this-code/8284 "2019-02-11T15:34:01Z")

</div>

hi all, i am extremely new to processing, as of a few hours. perhaps i’m jumping too quickly and trying to do something more complex without know the basics but I have been messing around with the code below. And what…

---

## [How can I avoid this error on mobile browsers?](https://discourse.processing.org/t/how-can-i-avoid-this-error-on-mobile-browsers/8255)

<div class="topic-metadata">

**Author:** [@chrisjj](https://discourse.processing.org/u/chrisjj)\
**Replies:** 1\
**Last updated:** [February 10, 2019, 11:09pm UTC](https://discourse.processing.org/t/how-can-i-avoid-this-error-on-mobile-browsers/8255 "2019-02-10T23:09:25Z")

</div>

When I try to run this openprocessing sketch on any mobile browser, when the touch is ended, I get an error Unable to dispatch event. Could anyone verify this? And suggest how I can avoid it?

---

## [How to create ripple effects over an image?](https://discourse.processing.org/t/how-to-create-ripple-effects-over-an-image/8227)

<div class="topic-metadata">

**Author:** [@artisan](https://discourse.processing.org/u/artisan)\
**Replies:** 3\
**Last updated:** [February 10, 2019, 10:59pm UTC](https://discourse.processing.org/t/how-to-create-ripple-effects-over-an-image/8227 "2019-02-10T22:59:20Z")

</div>

Ok, I am fairly new to processing so forgive me if this question is stupid or if this is not a suitable place to ask. The following code is taken from Dan Shiffman, The only modification made to this Is that I draw the …

---

## [How to make this wave movement?](https://discourse.processing.org/t/how-to-make-this-wave-movement/7911)

<div class="topic-metadata">

**Author:** [@Murky](https://discourse.processing.org/u/Murky)\
**Replies:** 7\
**Last updated:** [February 9, 2019, 7:39pm UTC](https://discourse.processing.org/t/how-to-make-this-wave-movement/7911 "2019-02-09T19:39:28Z")

</div>

Hello! I have found this Gif very interesting (credits to @beesandbombs). I am able to make the still version of the Gif in Processing, but I have no idea how to make it move like that? I don’t really know how can I …

---

## [Help with random map generator](https://discourse.processing.org/t/help-with-random-map-generator/8259)

<div class="topic-metadata">

**Author:** [@velosarahptor](https://discourse.processing.org/u/velosarahptor)\
**Replies:** 2\
**Last updated:** [February 10, 2019, 9:32am UTC](https://discourse.processing.org/t/help-with-random-map-generator/8259 "2019-02-10T09:32:03Z")

</div>

This is my first time using processing, and I’m creating a project for a class. I want to make a random map generator using 100x100 pixel image tiles. The idea is that the tiles are placed in random spots when certain ke…

---

## [Add an ArrayList to another ArrayList](https://discourse.processing.org/t/add-an-arraylist-to-another-arraylist/8187)

<div class="topic-metadata">

**Author:** [@vincentstrebelle](https://discourse.processing.org/u/vincentstrebelle)\
**Replies:** 24\
**Last updated:** [February 9, 2019, 6:33pm UTC](https://discourse.processing.org/t/add-an-arraylist-to-another-arraylist/8187 "2019-02-09T18:33:39Z")

</div>

Hi, i have 2 almost identical classes of objects (the color change) they have the same action : a random position without overlapping. Its work, but now i wonder how do i manage to place every objects with a random posi…

---

## [Rotate lines in the middle of the square](https://discourse.processing.org/t/rotate-lines-in-the-middle-of-the-square/8215)

<div class="topic-metadata">

**Author:** [@ClashAdam](https://discourse.processing.org/u/ClashAdam)\
**Replies:** 4\
**Last updated:** [February 8, 2019, 4:43pm UTC](https://discourse.processing.org/t/rotate-lines-in-the-middle-of-the-square/8215 "2019-02-08T16:43:28Z")

</div>

Can some1 help me please? I want to make these lines in the middle of the square rotating but i actually can’t. I tried…again…some processing coding, and…unfortunately…it showed me rotate error. thx for help float angle…

---

## [PImage.resize() does not resize to specified width](https://discourse.processing.org/t/pimage-resize-does-not-resize-to-specified-width/8217)

<div class="topic-metadata">

**Author:** [@Lucca](https://discourse.processing.org/u/Lucca)\
**Replies:** 2\
**Last updated:** [February 8, 2019, 3:45pm UTC](https://discourse.processing.org/t/pimage-resize-does-not-resize-to-specified-width/8217 "2019-02-08T15:45:38Z")

</div>

Hey fellow Processors, I am trying to crop a PImage and then resize it to its original width. Essentially, I am trying to get rid of the black border on the left side of the PImage: Unfortunately, if I use PImage.ge…

---

## [PVector: setting force of vector to something](https://discourse.processing.org/t/pvector-setting-force-of-vector-to-something/7481)

<div class="topic-metadata">

**Author:** [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Replies:** 9\
**Last updated:** [February 7, 2019, 9:53pm UTC](https://discourse.processing.org/t/pvector-setting-force-of-vector-to-something/7481 "2019-02-07T21:53:33Z")

</div>

Recently 3Blue1Brown posted vid: calculating PI with physics, and i wanted to recreate it in processing. I know it would be inacurate representation of it, but i want to challenge myself. So, how can i se…

---

## [Cartesian to Spherical coordinates conversion issue](https://discourse.processing.org/t/cartesian-to-spherical-coordinates-conversion-issue/8174)

<div class="topic-metadata">

**Author:** [@kesson](https://discourse.processing.org/u/kesson)\
**Replies:** 2\
**Last updated:** [February 7, 2019, 11:02am UTC](https://discourse.processing.org/t/cartesian-to-spherical-coordinates-conversion-issue/8174 "2019-02-07T11:02:43Z")

</div>

Hi everyone, I am trying to convert the cartesian coordinates a PVector in 3D space, with coordinates (x, y, z) in spherical coordinates (so obtaining radius, theta and phi). Below is the code I am testing, rarely it “…

---

## [PGraphics P2D background in setup issue](https://discourse.processing.org/t/pgraphics-p2d-background-in-setup-issue/8112)

<div class="topic-metadata">

**Author:** [@wqt](https://discourse.processing.org/u/wqt)\
**Replies:** 3\
**Last updated:** [February 6, 2019, 8:04pm UTC](https://discourse.processing.org/t/pgraphics-p2d-background-in-setup-issue/8112 "2019-02-06T20:04:40Z")

</div>

Hi there. I am using a PGraphics as a mask, the PGraphics’s background is set in the setup section so that my mask is not erased every frame. Somehow that works fine with the default renderer, but not in P2D, there is …

---

## [Default argument like c++](https://discourse.processing.org/t/default-argument-like-c/8131)

<div class="topic-metadata">

**Author:** [@diazdaiz](https://discourse.processing.org/u/diazdaiz)\
**Replies:** 2\
**Last updated:** [February 6, 2019, 7:42pm UTC](https://discourse.processing.org/t/default-argument-like-c/8131 "2019-02-06T19:42:27Z")

</div>

is there a way so i can write default argument in processing like c++? in c++, for example: void test(a=100) { … //some function that print value of a } so, when we call the function of test, if we dont passed val…

---

## [Help with delay/millis without influencing the framerate](https://discourse.processing.org/t/help-with-delay-millis-without-influencing-the-framerate/8153)

<div class="topic-metadata">

**Author:** [@jensemand](https://discourse.processing.org/u/jensemand)\
**Replies:** 6\
**Last updated:** [February 6, 2019, 4:45pm UTC](https://discourse.processing.org/t/help-with-delay-millis-without-influencing-the-framerate/8153 "2019-02-06T16:45:07Z")

</div>

Hi i am trying to make some text pop up each letter at a time by using a string while my framerate is at 60 however i can not use delay() because it would influence the framerate. How can i do this without using delay? p…

---

## [Random position without overlapping](https://discourse.processing.org/t/random-position-without-overlapping/7904)

<div class="topic-metadata">

**Author:** [@vincentstrebelle](https://discourse.processing.org/u/vincentstrebelle)\
**Replies:** 17\
**Last updated:** [February 6, 2019, 11:48am UTC](https://discourse.processing.org/t/random-position-without-overlapping/7904 "2019-02-06T11:48:51Z")

</div>

Hi i try to find a way to place objects on my world but without overlapping and i cant find a way. here’s my code: public class World2 { PApplet parent; public int worldW = 2000; public int worldH = 2000; Playe…

---

## [To stop part of drawings from being removed at update](https://discourse.processing.org/t/to-stop-part-of-drawings-from-being-removed-at-update/8017)

<div class="topic-metadata">

**Author:** [@Ismaiel\_Ahmed](https://discourse.processing.org/u/Ismaiel_Ahmed)\
**Replies:** 4\
**Last updated:** [February 6, 2019, 6:03am UTC](https://discourse.processing.org/t/to-stop-part-of-drawings-from-being-removed-at-update/8017 "2019-02-06T06:03:42Z")

</div>

I’m trying to simulate DDMR (Differential Drive Mobile Robot) However, draw() method makes update to all the shape and erase the previous frame I need to draw a specific shape and prevent it from being updated or remov…

---

## [Save a text file without utf 8](https://discourse.processing.org/t/save-a-text-file-without-utf-8/8061)

<div class="topic-metadata">

**Author:** [@Grimtin10](https://discourse.processing.org/u/Grimtin10)\
**Replies:** 2\
**Last updated:** [February 6, 2019, 4:10am UTC](https://discourse.processing.org/t/save-a-text-file-without-utf-8/8061 "2019-02-06T04:10:08Z")

</div>

How do I save a text file in Processing without it converting to UTF-8? Please help. Thanks.

---

## [Programming question, pertaining to motion](https://discourse.processing.org/t/programming-question-pertaining-to-motion/8070)

<div class="topic-metadata">

**Author:** [@superman](https://discourse.processing.org/u/superman)\
**Replies:** 6\
**Last updated:** [February 6, 2019, 12:53am UTC](https://discourse.processing.org/t/programming-question-pertaining-to-motion/8070 "2019-02-06T00:53:04Z")

</div>

I have an item obeying the laws of “projectile throw” which travels expected. If it lands on a ramph(opposite the launch), I want it’s trajectory to change–from the former path, projectile throw, to a normal path up the…

---

## [Need help with creating a quiz](https://discourse.processing.org/t/need-help-with-creating-a-quiz/8133)

<div class="topic-metadata">

**Author:** [@juriaan](https://discourse.processing.org/u/juriaan)\
**Replies:** 6\
**Last updated:** [February 5, 2019, 3:53pm UTC](https://discourse.processing.org/t/need-help-with-creating-a-quiz/8133 "2019-02-05T15:53:21Z")

</div>

Hey guys, I’m new here to the forums and processing. For school I’m trying to create a quiz that makes a shape based on your answers. I want to have around 4 questions with just two answers. Now what I can’t seem to f…

---

## [Unexpected token - void](https://discourse.processing.org/t/unexpected-token-void/8099)

<div class="topic-metadata">

**Author:** [@ClashAdam](https://discourse.processing.org/u/ClashAdam)\
**Replies:** 3\
**Last updated:** [February 5, 2019, 10:12am UTC](https://discourse.processing.org/t/unexpected-token-void/8099 "2019-02-05T10:12:49Z")

</div>

This errors shows for no reason, in first tab Drop\[\] drops = new Drop\[500\] void setup() { size(640, 360) ; for (int i = 0; i \< drops.length; i++) { drops\[i\] i = new Drop() ; } } void draw() { background(23…

---

## [Changing the size of shape based on values from Data Set](https://discourse.processing.org/t/changing-the-size-of-shape-based-on-values-from-data-set/8100)

<div class="topic-metadata">

**Author:** [@CalumDixon](https://discourse.processing.org/u/CalumDixon)\
**Replies:** 11\
**Last updated:** [February 5, 2019, 8:39am UTC](https://discourse.processing.org/t/changing-the-size-of-shape-based-on-values-from-data-set/8100 "2019-02-05T08:39:06Z")

</div>

Hey, I’m still pretty new to processing so I doubt this a very complicated issue. I’m trying to visualise a data set of earthquakes around the world, but I’m struggling to make the markers increase in size based on the …

---

## [Cannot refer to the non-final local variable ... defined in an enclosing scope](https://discourse.processing.org/t/cannot-refer-to-the-non-final-local-variable-defined-in-an-enclosing-scope/8023)

<div class="topic-metadata">

**Author:** [@Renaud](https://discourse.processing.org/u/Renaud)\
**Replies:** 4\
**Last updated:** [February 5, 2019, 7:51am UTC](https://discourse.processing.org/t/cannot-refer-to-the-non-final-local-variable-defined-in-an-enclosing-scope/8023 "2019-02-05T07:51:09Z")

</div>

Hi, I am trying a code found on the internet (below). When I run it, I obtain this message: “cannot refer to the non-final local variable startw defined in an enclosing scope” What is it supposed to mean ? What can I d…

---

## [Basic PShader Issue](https://discourse.processing.org/t/basic-pshader-issue/8094)

<div class="topic-metadata">

**Author:** [@eduzal](https://discourse.processing.org/u/eduzal)\
**Replies:** 3\
**Last updated:** [February 5, 2019, 3:19am UTC](https://discourse.processing.org/t/basic-pshader-issue/8094 "2019-02-05T03:19:50Z")

</div>

Having some trouble passing an PImage to PShader. Doing something wrong, but can’t figure it out. First I’m trying to work with image before moving to video. tks in advance. basic code PShader displace; PImage moon; b…

---

## [Stacker game- game over if not properly stacked](https://discourse.processing.org/t/stacker-game-game-over-if-not-properly-stacked/8006)

<div class="topic-metadata">

**Author:** [@kjanek](https://discourse.processing.org/u/kjanek)\
**Replies:** 2\
**Last updated:** [February 5, 2019, 3:17am UTC](https://discourse.processing.org/t/stacker-game-game-over-if-not-properly-stacked/8006 "2019-02-05T03:17:37Z")

</div>

So I’m modifying this code, and I can’t figure out how to make it so that the only way to progress through the game is for the block the player places to land exactly on top of the block placed previously. Currently, the…

---

## [Animating an object from one position to other](https://discourse.processing.org/t/animating-an-object-from-one-position-to-other/7995)

<div class="topic-metadata">

**Author:** [@sim](https://discourse.processing.org/u/sim)\
**Replies:** 5\
**Last updated:** [February 4, 2019, 10:17pm UTC](https://discourse.processing.org/t/animating-an-object-from-one-position-to-other/7995 "2019-02-04T22:17:57Z")

</div>

Hello there, I would really appreciated some help with this question that I’m stuck on. im trying to get an object to move from one position (last mouse click) to a new position (most recent mouse click). I’m familiar…

---

## [Spaces between objects within an array and between arrays](https://discourse.processing.org/t/spaces-between-objects-within-an-array-and-between-arrays/8107)

<div class="topic-metadata">

**Author:** [@german\_guy](https://discourse.processing.org/u/german_guy)\
**Replies:** 2\
**Last updated:** [February 4, 2019, 8:43pm UTC](https://discourse.processing.org/t/spaces-between-objects-within-an-array-and-between-arrays/8107 "2019-02-04T20:43:32Z")

</div>

Guys, I got a question. I am a beginner at coding. I am trying to program a little game but I’m already stuck. Basically, I have set up two arrays with a number of objects within both of them. Now I’ve encountered a li…

---

## [\[SOLVED\] PGraphics.image gives NullPointerException](https://discourse.processing.org/t/solved-pgraphics-image-gives-nullpointerexception/8076)

<div class="topic-metadata">

**Author:** [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Replies:** 1\
**Last updated:** [February 3, 2019, 6:36pm UTC](https://discourse.processing.org/t/solved-pgraphics-image-gives-nullpointerexception/8076 "2019-02-03T18:36:22Z")

</div>

I created a sketch with a PImage that I was then going to draw into a PGraphics using PGraphics.image() – but I got a NullPointerException. Why is this happening? I have created an MCVE below to demonstrate the problem…

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

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