# Coding Questions

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

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

**Page:** 26

---

## [How to optimize HSB color comparisons?](https://discourse.processing.org/t/how-to-optimize-hsb-color-comparisons/38551)

<div class="topic-metadata">

**Author:** [@i-make-robots](https://discourse.processing.org/u/i-make-robots)\
**Replies:** 1\
**Last updated:** [August 29, 2022, 10:23pm UTC](https://discourse.processing.org/t/how-to-optimize-hsb-color-comparisons/38551 "2022-08-29T22:23:03Z")

</div>

This sketch takes a picture and interprets it as though it was woven from colored string wrapped around a circle of nails. It was originally written in RGB space where I am most comfortable. I tried swapping out the …

---

## [Confusing Syntax Error Code (TicTacToe)](https://discourse.processing.org/t/confusing-syntax-error-code-tictactoe/38550)

<div class="topic-metadata">

**Author:** [@user10012201](https://discourse.processing.org/u/user10012201)\
**Replies:** 6\
**Last updated:** [August 29, 2022, 9:20pm UTC](https://discourse.processing.org/t/confusing-syntax-error-code-tictactoe/38550 "2022-08-29T21:20:53Z")

</div>

I am trying to make a TicTacToe game as part of a java lesson I am following along with. I completed the lesson, but there is a single line that processing claims is a syntax error that is stopping it from compiling. I c…

---

## [How to Read Data from Google Calendar (or similar) in Processing](https://discourse.processing.org/t/how-to-read-data-from-google-calendar-or-similar-in-processing/38525)

<div class="topic-metadata">

**Author:** [@CaseyJ](https://discourse.processing.org/u/CaseyJ)\
**Replies:** 1\
**Last updated:** [August 27, 2022, 7:17pm UTC](https://discourse.processing.org/t/how-to-read-data-from-google-calendar-or-similar-in-processing/38525 "2022-08-27T19:17:08Z")

</div>

I have been thinking of ways to read data from a collaborative cloud based calendar, like Google Calendar. I imagine there may be other services but let’s roll with this one for now. Would it be possible to read data fr…

---

## [How to map an object to JSON in Processing](https://discourse.processing.org/t/how-to-map-an-object-to-json-in-processing/38432)

<div class="topic-metadata">

**Author:** [@Rico](https://discourse.processing.org/u/Rico)\
**Replies:** 2\
**Last updated:** [August 27, 2022, 4:49pm UTC](https://discourse.processing.org/t/how-to-map-an-object-to-json-in-processing/38432 "2022-08-27T16:49:29Z")

</div>

Hi all, I’ve been looking into various ways of mapping object to json in Processing and I can’t seem to get anything to work. I have tried GSON, Javax and Jackson. but all throw errors. Maybe I’m not loading all the de…

---

## [Dynamically Setting the Window as Undecorated](https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327)

<div class="topic-metadata">

**Author:** [@Brahvim](https://discourse.processing.org/u/Brahvim)\
**Replies:** 5\
**Last updated:** [August 26, 2022, 12:02pm UTC](https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327 "2022-08-26T12:02:49Z")

</div>

Just as the title says: I want to be able to set the window as ‘undecorated’, while the sketch is running. It causes some errors inside “handleDraw()”, however. I felt that it may be possible if I call noLoop(), wait f…

---

## [Can't detect PDE vs command line, PDE no longer passing --external](https://discourse.processing.org/t/cant-detect-pde-vs-command-line-pde-no-longer-passing-external/10508)

<div class="topic-metadata">

**Author:** [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Replies:** 9\
**Last updated:** [August 26, 2022, 11:49am UTC](https://discourse.processing.org/t/cant-detect-pde-vs-command-line-pde-no-longer-passing-external/10508 "2022-08-26T11:49:54Z")

</div>

Two years ago I developed a sketch that could be run from PDE or from the command line (processing-java) – optionally with arguments. I wanted the sketch to know which way it had been run (PDE or command line). Detect …

---

## [Simple Sketch Lagging Despite Low Draw Time](https://discourse.processing.org/t/simple-sketch-lagging-despite-low-draw-time/38491)

<div class="topic-metadata">

**Author:** [@sudonym](https://discourse.processing.org/u/sudonym)\
**Replies:** 3\
**Last updated:** [August 26, 2022, 5:12am UTC](https://discourse.processing.org/t/simple-sketch-lagging-despite-low-draw-time/38491 "2022-08-26T05:12:57Z")

</div>

I have been using Processing for a while, and though my code can get pretty long it never lags. However, while working on this relatively simple sketch the display lags like crazy (~3-4fps). This is the code for my sket…

---

## [Creating SVG limited to canvas size](https://discourse.processing.org/t/creating-svg-limited-to-canvas-size/38426)

<div class="topic-metadata">

**Author:** [@i-draw-monkeys](https://discourse.processing.org/u/i-draw-monkeys)\
**Replies:** 13\
**Last updated:** [August 25, 2022, 6:52am UTC](https://discourse.processing.org/t/creating-svg-limited-to-canvas-size/38426 "2022-08-25T06:52:36Z")

</div>

I am just learning Processing to make files for the Axidraw. I have figured out my best workflow in terms of saving SVGs but just hit a snag. I am using simplified code for this example here using one line (but in the fi…

---

## [Splitting a list of ints, using a special number as a "separator"](https://discourse.processing.org/t/splitting-a-list-of-ints-using-a-special-number-as-a-separator/38471)

<div class="topic-metadata">

**Author:** [@eltrem](https://discourse.processing.org/u/eltrem)\
**Replies:** 10\
**Last updated:** [August 24, 2022, 10:02pm UTC](https://discourse.processing.org/t/splitting-a-list-of-ints-using-a-special-number-as-a-separator/38471 "2022-08-24T22:02:27Z")

</div>

I’m trying to split an incoming list of numbers to fill an ArrayList. Each new chopped IntList would have a different size, and on the incoming -unchopped- list i can use -1 as the separator. I’m having problems to pars…

---

## [Saving SVG: I only want to save the canvas, not lines drawn outside](https://discourse.processing.org/t/saving-svg-i-only-want-to-save-the-canvas-not-lines-drawn-outside/38421)

<div class="topic-metadata">

**Author:** [@i-draw-monkeys](https://discourse.processing.org/u/i-draw-monkeys)\
**Replies:** 1\
**Last updated:** [August 21, 2022, 9:02pm UTC](https://discourse.processing.org/t/saving-svg-i-only-want-to-save-the-canvas-not-lines-drawn-outside/38421 "2022-08-21T21:02:17Z")

</div>

I am trying to make some SVGs for my pen plotter using math to draw lines. I define the canvas size in setup, but some points that the math designates are outside of this. Here is example code that I simplified where thi…

---

## [TRIANGLE\_STRIP lighting problem](https://discourse.processing.org/t/triangle-strip-lighting-problem/38348)

<div class="topic-metadata">

**Author:** [@Tsskyx](https://discourse.processing.org/u/Tsskyx)\
**Replies:** 9\
**Last updated:** [August 21, 2022, 3:31am UTC](https://discourse.processing.org/t/triangle-strip-lighting-problem/38348 "2022-08-21T03:31:12Z")

</div>

I want to add some simple lighting to my 3D terrain that I’m generating using beginShape with TRIANGLE\_STRIP like this: for (int i = 0; i \< count - 1; i++) { beginShape(TRIANGLE\_STRIP); for (int j = 0; j \< count; j+…

---

## [Creating Stills](https://discourse.processing.org/t/creating-stills/38284)

<div class="topic-metadata">

**Author:** [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Replies:** 16\
**Last updated:** [August 19, 2022, 4:51pm UTC](https://discourse.processing.org/t/creating-stills/38284 "2022-08-19T16:51:58Z")

</div>

Hi, I used the following code under void draw(); in order to save images of my code rather than a screenshot. When I do so, I receive an error message saying Error “void”? void keyPressed(){ if(keyCode == ENTER){ …

---

## [Circulo con loop](https://discourse.processing.org/t/circulo-con-loop/38373)

<div class="topic-metadata">

**Author:** [@Eghost](https://discourse.processing.org/u/Eghost)\
**Replies:** 3\
**Last updated:** [August 16, 2022, 6:55am UTC](https://discourse.processing.org/t/circulo-con-loop/38373 "2022-08-16T06:55:44Z")

</div>

please format code with \</\> button \* homework policy \* asking questions quiero que el circulo interior y el loop tengan color

---

## [Delaying/Changing the speed of a section of code without delaying the entire code](https://discourse.processing.org/t/delaying-changing-the-speed-of-a-section-of-code-without-delaying-the-entire-code/38357)

<div class="topic-metadata">

**Author:** [@Isobelcameron](https://discourse.processing.org/u/Isobelcameron)\
**Replies:** 4\
**Last updated:** [August 15, 2022, 1:26pm UTC](https://discourse.processing.org/t/delaying-changing-the-speed-of-a-section-of-code-without-delaying-the-entire-code/38357 "2022-08-15T13:26:25Z")

</div>

Hi! I am trying to delay expanding ball 2 so that it starts expanding after expanding ball 1. I have tried the pushMatrix(); and popMatrix(); which made my program crash and I also tried the delay example on the process…

---

## [Altering global variables of a processing code running via processing.js within an html page](https://discourse.processing.org/t/altering-global-variables-of-a-processing-code-running-via-processing-js-within-an-html-page/38330)

<div class="topic-metadata">

**Author:** [@anrui71](https://discourse.processing.org/u/anrui71)\
**Replies:** 0\
**Last updated:** [August 12, 2022, 8:53pm UTC](https://discourse.processing.org/t/altering-global-variables-of-a-processing-code-running-via-processing-js-within-an-html-page/38330 "2022-08-12T20:53:33Z")

</div>

Hello everyone, I am currently trying to find a way to alter the values of some global variables of a processing code running in an html page through user value input on the html page. Generally, when importing an sepa…

---

## [Windows Sketch Screen Size Problem](https://discourse.processing.org/t/windows-sketch-screen-size-problem/38298)

<div class="topic-metadata">

**Author:** [@searchingforananswer](https://discourse.processing.org/u/searchingforananswer)\
**Replies:** 5\
**Last updated:** [August 11, 2022, 9:21pm UTC](https://discourse.processing.org/t/windows-sketch-screen-size-problem/38298 "2022-08-11T21:21:11Z")

</div>

Hello everyone, I got this problem. When I’m working on Mac, I can see my design in sketch screen as exactly as I coded. But then when I try to open in my Windows laptop, I see the screen size different. In my last draft…

---

## [GLSL / Shader particle system - how to store and retrieve data from a buffer](https://discourse.processing.org/t/glsl-shader-particle-system-how-to-store-and-retrieve-data-from-a-buffer/38253)

<div class="topic-metadata">

**Author:** [@zenglenn](https://discourse.processing.org/u/zenglenn)\
**Replies:** 3\
**Last updated:** [August 8, 2022, 2:01pm UTC](https://discourse.processing.org/t/glsl-shader-particle-system-how-to-store-and-retrieve-data-from-a-buffer/38253 "2022-08-08T14:01:40Z")

</div>

So I’m trying to create a particle system using a frag shader - for purposes of fast GPU use. I know this can be done by using a texture to store all the particle info like position and velocity etc. I know how to encod…

---

## [Reversed Round Function](https://discourse.processing.org/t/reversed-round-function/38274)

<div class="topic-metadata">

**Author:** [@Mattyjak](https://discourse.processing.org/u/Mattyjak)\
**Replies:** 3\
**Last updated:** [August 8, 2022, 7:37am UTC](https://discourse.processing.org/t/reversed-round-function/38274 "2022-08-08T07:37:30Z")

</div>

Hello fellow programmers! I was working on a small code snippet and I ran into an issue. In my project, I use floor() to convert from global coordinates to “chunk” coordinates via a simple mathematic equation: floor(gl…

---

## [Rasterize Image/ Flowfield with Noise values from image](https://discourse.processing.org/t/rasterize-image-flowfield-with-noise-values-from-image/38176)

<div class="topic-metadata">

**Author:** [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Replies:** 12\
**Last updated:** [August 7, 2022, 6:05pm UTC](https://discourse.processing.org/t/rasterize-image-flowfield-with-noise-values-from-image/38176 "2022-08-07T18:05:35Z")

</div>

Hi, how can I change the code below to shift lines that respond to the image file? Via Coding Challenge #24: Perlin Noise Flow Field PImage img; void setup(){ size(900, 900, P3D); img = loadImage("Jan24.jpg"); …

---

## [How to link grid to image as a height map](https://discourse.processing.org/t/how-to-link-grid-to-image-as-a-height-map/38254)

<div class="topic-metadata">

**Author:** [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Replies:** 2\
**Last updated:** [August 7, 2022, 1:42pm UTC](https://discourse.processing.org/t/how-to-link-grid-to-image-as-a-height-map/38254 "2022-08-07T13:42:47Z")

</div>

I’m interested in morphing the grid with randomness while also having an image interact with the grid. How do I go about designing varying cells and joining them together as a grid image? Can I use the random(); with (TR…

---

## [Issue when rendering small rectangles](https://discourse.processing.org/t/issue-when-rendering-small-rectangles/38217)

<div class="topic-metadata">

**Author:** [@ishback](https://discourse.processing.org/u/ishback)\
**Replies:** 4\
**Last updated:** [August 7, 2022, 12:49am UTC](https://discourse.processing.org/t/issue-when-rendering-small-rectangles/38217 "2022-08-07T00:49:15Z")

</div>

Hi, I’m trying to render noSmooth small rectangles, and I don’t know why I’m getting them non simmetrical (1st one), or not centered (2nd one). Do you know what’s the reason?

---

## [Disable display](https://discourse.processing.org/t/disable-display/38236)

<div class="topic-metadata">

**Author:** [@mothsa](https://discourse.processing.org/u/mothsa)\
**Replies:** 1\
**Last updated:** [August 5, 2022, 3:25pm UTC](https://discourse.processing.org/t/disable-display/38236 "2022-08-05T15:25:21Z")

</div>

Hi everyone, This is my first time using processing, and I’d like to generate png files when running processing code from command-line. This part works fine, but I’m having trouble disabling previews. I saw this tutoria…

---

## [Searching the internet](https://discourse.processing.org/t/searching-the-internet/38219)

<div class="topic-metadata">

**Author:** [@TheGreatTardonio](https://discourse.processing.org/u/TheGreatTardonio)\
**Replies:** 0\
**Last updated:** [August 4, 2022, 12:15pm UTC](https://discourse.processing.org/t/searching-the-internet/38219 "2022-08-04T12:15:38Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Let’s say I’m writing a program and I want it to be able to search the internet, for example I want it to search google with “What’s X lightyear…

---

## [Why does the frameRate drop so much when I load about 100 pictures into the program](https://discourse.processing.org/t/why-does-the-framerate-drop-so-much-when-i-load-about-100-pictures-into-the-program/38196)

<div class="topic-metadata">

**Author:** [@urlxd](https://discourse.processing.org/u/urlxd)\
**Replies:** 8\
**Last updated:** [August 3, 2022, 5:28am UTC](https://discourse.processing.org/t/why-does-the-framerate-drop-so-much-when-i-load-about-100-pictures-into-the-program/38196 "2022-08-03T05:28:04Z")

</div>

hello, i would like to know. why does the frameRate drop so much when I load about 100 pictures into the program. And how to fix it. Pictures from one color, with squares there is no such thing. :neutral\_face:

---

## [Creating variation in grid with random();](https://discourse.processing.org/t/creating-variation-in-grid-with-random/38175)

<div class="topic-metadata">

**Author:** [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Replies:** 8\
**Last updated:** [August 3, 2022, 11:06am UTC](https://discourse.processing.org/t/creating-variation-in-grid-with-random/38175 "2022-08-03T11:06:04Z")

</div>

Hi! I’m wondering how I can go about creating a grid like the example in the screenshot below. I’m interested in morphing the grid with randomness. How do I go about designing varying cells and joining them together as…

---

## [How to access object by using it's name in string format?](https://discourse.processing.org/t/how-to-access-object-by-using-its-name-in-string-format/38182)

<div class="topic-metadata">

**Author:** [@Ghostsss](https://discourse.processing.org/u/Ghostsss)\
**Replies:** 9\
**Last updated:** [August 2, 2022, 2:46pm UTC](https://discourse.processing.org/t/how-to-access-object-by-using-its-name-in-string-format/38182 "2022-08-02T14:46:12Z")

</div>

Hello, In the following example: I want to get the p2.y using str. I searched a lot but couldn’t find how to do this. (I am new to java) Please Help. void setup(){ cord p1 = new cord(2,3); cord p2 = new cord(77,88)…

---

## [How to translate an object in Z - but keep its screen X and Y pos?](https://discourse.processing.org/t/how-to-translate-an-object-in-z-but-keep-its-screen-x-and-y-pos/38171)

<div class="topic-metadata">

**Author:** [@zenglenn](https://discourse.processing.org/u/zenglenn)\
**Replies:** 9\
**Last updated:** [July 31, 2022, 9:43pm UTC](https://discourse.processing.org/t/how-to-translate-an-object-in-z-but-keep-its-screen-x-and-y-pos/38171 "2022-07-31T21:43:51Z")

</div>

How would I move a 3d point away / toward the camera - but have its position locked on a particular screen x y coordinate?

---

## [Clip function crashes live html canvas (unresolved)](https://discourse.processing.org/t/clip-function-crashes-live-html-canvas-unresolved/38150)

<div class="topic-metadata">

**Author:** [@canslp](https://discourse.processing.org/u/canslp)\
**Replies:** 8\
**Last updated:** [July 31, 2022, 8:29am UTC](https://discourse.processing.org/t/clip-function-crashes-live-html-canvas-unresolved/38150 "2022-07-31T08:29:14Z")

</div>

not sure quite how to even phrase this question but i’m trying to use the clip function and it works fine on local processing, but in my live html canvas (with processing.js) invoking it in any capacity, even just using …

---

## [Faster way to draw part of an image?](https://discourse.processing.org/t/faster-way-to-draw-part-of-an-image/38140)

<div class="topic-metadata">

**Author:** [@canslp](https://discourse.processing.org/u/canslp)\
**Replies:** 6\
**Last updated:** [July 30, 2022, 3:27pm UTC](https://discourse.processing.org/t/faster-way-to-draw-part-of-an-image/38140 "2022-07-30T15:27:49Z")

</div>

i need to be able to draw the top part of an image, here’s what i have void drawImageSplice(PGraphics pg,PImage img,int x,int y,int w,int h,float cut){ int yp = round(h\*cut); if(yp\>0){ PGraphics buffer = createG…

---

## [NullPointerException returned](https://discourse.processing.org/t/nullpointerexception-returned/31818)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 6\
**Last updated:** [August 21, 2021, 1:45pm UTC](https://discourse.processing.org/t/nullpointerexception-returned/31818 "2021-08-21T13:45:06Z")

</div>

why does the following code return NullPointerException? int fistleft=1; int fistright=2; int clapleft=3; int clapright=4; int choice1; int choice2; int\[\] correct; int i=0; void draw(){ //zet choice1 en choice2 naa…

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

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