# Coding Questions

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

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

**Page:** 130

---

## [Drawing the inverse of a circle in a bounding rectangle](https://discourse.processing.org/t/drawing-the-inverse-of-a-circle-in-a-bounding-rectangle/13333)

<div class="topic-metadata">

**Author:** [@LoliProcessor](https://discourse.processing.org/u/LoliProcessor)\
**Replies:** 2\
**Last updated:** [August 15, 2019, 4:17pm UTC](https://discourse.processing.org/t/drawing-the-inverse-of-a-circle-in-a-bounding-rectangle/13333 "2019-08-15T16:17:14Z")

</div>

I am trying to draw an overlay for the rounded corner of cards. There is the rounded corners mode by drawing regular rectangles, but the cards are stored in images. Is there a more efficient method in processing other …

---

## [About map and error checking and preventing](https://discourse.processing.org/t/about-map-and-error-checking-and-preventing/13211)

<div class="topic-metadata">

**Author:** [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Replies:** 3\
**Last updated:** [August 15, 2019, 2:18pm UTC](https://discourse.processing.org/t/about-map-and-error-checking-and-preventing/13211 "2019-08-15T14:18:12Z")

</div>

map was once a simple function 4 times faster that looked like this: static public float map(float value, float istart, float istop, float ostart, float ostop) { return ostart + (ostop - ostart) \* ((value - istart) …

---

## [Different values for position when rotating around a circle](https://discourse.processing.org/t/different-values-for-position-when-rotating-around-a-circle/13395)

<div class="topic-metadata">

**Author:** [@fedpep](https://discourse.processing.org/u/fedpep)\
**Replies:** 8\
**Last updated:** [August 15, 2019, 1:39pm UTC](https://discourse.processing.org/t/different-values-for-position-when-rotating-around-a-circle/13395 "2019-08-15T13:39:28Z")

</div>

Hello, I was refactoring some old code and I noticed a problem with this sketch. It starts getting weird when there are 7 or 11, 13 (ad so on…) values in the array. I’m sure that’s because there are floating variables bu…

---

## [Need help - changeable text screen output](https://discourse.processing.org/t/need-help-changeable-text-screen-output/13374)

<div class="topic-metadata">

**Author:** [@waffi](https://discourse.processing.org/u/waffi)\
**Replies:** 5\
**Last updated:** [August 15, 2019, 9:04am UTC](https://discourse.processing.org/t/need-help-changeable-text-screen-output/13374 "2019-08-15T09:04:12Z")

</div>

how can you output a changing text, which comes via a serial interface on the screen output? the problem is that the first text always stops and then it runs into each other. example: textSize(100); fill(0, 139, 0,…

---

## [Fighting game java](https://discourse.processing.org/t/fighting-game-java/13295)

<div class="topic-metadata">

**Author:** [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Replies:** 6\
**Last updated:** [August 14, 2019, 7:11pm UTC](https://discourse.processing.org/t/fighting-game-java/13295 "2019-08-14T19:11:37Z")

</div>

I’m making a fighting game where warriors come from both sides and meet in the middle. ATM I placed them in the middle because the map not done yet. Anyways I was trying to set up the fight but the way i’m trying to do i…

---

## [Trouble with keyCode](https://discourse.processing.org/t/trouble-with-keycode/13376)

<div class="topic-metadata">

**Author:** [@abigail](https://discourse.processing.org/u/abigail)\
**Replies:** 3\
**Last updated:** [August 14, 2019, 6:51pm UTC](https://discourse.processing.org/t/trouble-with-keycode/13376 "2019-08-14T18:51:47Z")

</div>

Hi, so I’m trying to move a square around the screen using the arrow keys. I have the code written for the square to move right when the right arrow key is pressed, but the square keeps moving once the key is released. H…

---

## [Shape parameter for 3D position](https://discourse.processing.org/t/shape-parameter-for-3d-position/13352)

<div class="topic-metadata">

**Author:** [@kll](https://discourse.processing.org/u/kll)\
**Replies:** 2\
**Last updated:** [August 14, 2019, 1:24am UTC](https://discourse.processing.org/t/shape-parameter-for-3d-position/13352 "2019-08-14T01:24:01Z")

</div>

i know from https://processing.org/reference/shape\_.html shape(s) shape(s, x, y) shape(s, a, b, c, d) and s.translate(x, y) also it is possible to use in P3D s.translate(x, y, z) what is additive, so s.reset…

---

## [3D shape with a bad seam](https://discourse.processing.org/t/3d-shape-with-a-bad-seam/13218)

<div class="topic-metadata">

**Author:** [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Replies:** 18\
**Last updated:** [August 13, 2019, 2:42am UTC](https://discourse.processing.org/t/3d-shape-with-a-bad-seam/13218 "2019-08-13T02:42:03Z")

</div>

Hello all, I produced a 3D quadt\_strip shape, but not only one row but multiple. It’s kind of a circle (Moebius strip). Unfortunately I have a big seam (horizontal right side) I cannot get rid of. Can someone check m…

---

## [\[SOLVED\] Delete circles if mousePressed help?](https://discourse.processing.org/t/solved-delete-circles-if-mousepressed-help/4056)

<div class="topic-metadata">

**Author:** [@Mikaela](https://discourse.processing.org/u/Mikaela)\
**Replies:** 2\
**Last updated:** [October 4, 2018, 1:47pm UTC](https://discourse.processing.org/t/solved-delete-circles-if-mousepressed-help/4056 "2018-10-04T13:47:18Z")

</div>

I’m trying to figure out what’s the code to make the circles disappear if the mouse is pressed. If you know what it is, please share it! I pasted my code below thanks! // Lab 3 Question 7 // Write a program that draws …

---

## [\[SOLVED\] How to debug this timeout error](https://discourse.processing.org/t/solved-how-to-debug-this-timeout-error/4383)

<div class="topic-metadata">

**Author:** [@ProsExplorer](https://discourse.processing.org/u/ProsExplorer)\
**Replies:** 0\
**Last updated:** [October 12, 2018, 6:04am UTC](https://discourse.processing.org/t/solved-how-to-debug-this-timeout-error/4383 "2018-10-12T06:04:20Z")

</div>

Conclusion: 10-15-2018 From what I’ve seen attempting to debug this and creating a hybrid version with an earlier boolean version there’s an issue with the classes function that causes the program to continuously load …

---

## [\[SOLVED\] Edge artifacts when random-access sampling a texture in a shader on Linux](https://discourse.processing.org/t/solved-edge-artifacts-when-random-access-sampling-a-texture-in-a-shader-on-linux/8382)

<div class="topic-metadata">

**Author:** [@scudly](https://discourse.processing.org/u/scudly)\
**Replies:** 0\
**Last updated:** [February 13, 2019, 10:30pm UTC](https://discourse.processing.org/t/solved-edge-artifacts-when-random-access-sampling-a-texture-in-a-shader-on-linux/8382 "2019-02-13T22:30:16Z")

</div>

Edit: This texture sampling bug only seems to occur on Linux. On both Windows 10 and Android, I can set point sampling with ((PGraphicsOpenGL)g).textureSampling(2); and get clean images, but on Linux, that line has no e…

---

## [\[SOLVED\] Downloading image, saving to specific folder](https://discourse.processing.org/t/solved-downloading-image-saving-to-specific-folder/11784)

<div class="topic-metadata">

**Author:** [@SoulT](https://discourse.processing.org/u/SoulT)\
**Replies:** 0\
**Last updated:** [June 2, 2019, 7:42pm UTC](https://discourse.processing.org/t/solved-downloading-image-saving-to-specific-folder/11784 "2019-06-02T19:42:35Z")

</div>

Howdy guys, I’m trying to set up a basic script that will download an image, and then save the image as a transparent PNG to a specific folder. Here’s what I have so far (I’ve replaced the url, for privacy sake. The act…

---

## [Need a hint about lights](https://discourse.processing.org/t/need-a-hint-about-lights/13073)

<div class="topic-metadata">

**Author:** [@LuckSmith](https://discourse.processing.org/u/LuckSmith)\
**Replies:** 8\
**Last updated:** [August 11, 2019, 10:55pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073 "2019-08-11T22:55:12Z")

</div>

Hi guys, Here’s a screenshot of a sketch I am currently working on. On the upper left corner is a minimap of the dungeon (only tiles that have been seen are shown). The little green arrow there represents the player …

---

## [Help with classes](https://discourse.processing.org/t/help-with-classes/13305)

<div class="topic-metadata">

**Author:** [@abigail](https://discourse.processing.org/u/abigail)\
**Replies:** 5\
**Last updated:** [August 11, 2019, 10:29am UTC](https://discourse.processing.org/t/help-with-classes/13305 "2019-08-11T10:29:25Z")

</div>

Hi, so I have a simple sketch of paint to colour in the background of a window. I want to make the colouring tool decrease and increase in size. Why does the code in the function changeSize not work? Thanks in advance. …

---

## [Problems parsing an UTF-8 string backwards](https://discourse.processing.org/t/problems-parsing-an-utf-8-string-backwards/13294)

<div class="topic-metadata">

**Author:** [@LuckSmith](https://discourse.processing.org/u/LuckSmith)\
**Replies:** 2\
**Last updated:** [August 10, 2019, 7:07pm UTC](https://discourse.processing.org/t/problems-parsing-an-utf-8-string-backwards/13294 "2019-08-10T19:07:53Z")

</div>

If I go forward like String str = "This is a string containing different encodings. В этой строке есть кириллица, например (2 bytes per char)"; for (int i=0; i\<str.length(); i++) { println(str.charAt(i)); } it works …

---

## [How to calculate the center of a circle inscribed in a circle sector](https://discourse.processing.org/t/how-to-calculate-the-center-of-a-circle-inscribed-in-a-circle-sector/13279)

<div class="topic-metadata">

**Author:** [@ddownn](https://discourse.processing.org/u/ddownn)\
**Replies:** 3\
**Last updated:** [August 10, 2019, 9:16am UTC](https://discourse.processing.org/t/how-to-calculate-the-center-of-a-circle-inscribed-in-a-circle-sector/13279 "2019-08-10T09:16:06Z")

</div>

I’m having trouble figuring out how to set “r” so that the small circle is inscribed within the sector. The number of sectors will vary. I would also appreciate help with math to calculate the points where the small circ…

---

## [Creating a grid with a PShape](https://discourse.processing.org/t/creating-a-grid-with-a-pshape/13268)

<div class="topic-metadata">

**Author:** [@thedurf18](https://discourse.processing.org/u/thedurf18)\
**Replies:** 12\
**Last updated:** [August 9, 2019, 5:41pm UTC](https://discourse.processing.org/t/creating-a-grid-with-a-pshape/13268 "2019-08-09T17:41:52Z")

</div>

How could I turn this code into a grid? I’d appreciate any help. int many = 10; PShape\[\] a = new PShape\[many\]; void setup() { size(1680, 1005, P3D); make\_shapes(); } void make\_shapes() { for (int i = 0; i \< many…

---

## [Accessing pixel values just above a line](https://discourse.processing.org/t/accessing-pixel-values-just-above-a-line/13145)

<div class="topic-metadata">

**Author:** [@eric](https://discourse.processing.org/u/eric)\
**Replies:** 7\
**Last updated:** [August 8, 2019, 9:25pm UTC](https://discourse.processing.org/t/accessing-pixel-values-just-above-a-line/13145 "2019-08-08T21:25:12Z")

</div>

I’m trying to see if the pixel is black or white, and then move on to the next pixel down the line. I’ve gotten flat lines down, I just keep track of the endpoints of the line, and add 2 to not count the line’s color. …

---

## [Call a procedure by its name in String](https://discourse.processing.org/t/call-a-procedure-by-its-name-in-string/13249)

<div class="topic-metadata">

**Author:** [@LuckSmith](https://discourse.processing.org/u/LuckSmith)\
**Replies:** 8\
**Last updated:** [August 8, 2019, 6:24pm UTC](https://discourse.processing.org/t/call-a-procedure-by-its-name-in-string/13249 "2019-08-08T18:24:27Z")

</div>

Ok, so you can do like thread("myProcedure"); but it creates a new thread. Is it possible to call a procedure in a similar way it the main thread? Or even maybe there is a way to execute code in a String? Like Strin…

---

## [How do I get my sketch to perform faster?](https://discourse.processing.org/t/how-do-i-get-my-sketch-to-perform-faster/13146)

<div class="topic-metadata">

**Author:** [@thedurf18](https://discourse.processing.org/u/thedurf18)\
**Replies:** 4\
**Last updated:** [August 8, 2019, 12:57am UTC](https://discourse.processing.org/t/how-do-i-get-my-sketch-to-perform-faster/13146 "2019-08-08T00:57:33Z")

</div>

I have written a sketch that is almost 6000 lines, and I’m still not done. I wanted to check my progress so far to see how the animation is running, and it is very laggy. I tried increasing frame rate to 30 and 60, and i…

---

## [Issue when loading SVG file: Distortion with P2D or P3D renderer](https://discourse.processing.org/t/issue-when-loading-svg-file-distortion-with-p2d-or-p3d-renderer/13190)

<div class="topic-metadata">

**Author:** [@uli-b](https://discourse.processing.org/u/uli-b)\
**Replies:** 3\
**Last updated:** [August 7, 2019, 8:37pm UTC](https://discourse.processing.org/t/issue-when-loading-svg-file-distortion-with-p2d-or-p3d-renderer/13190 "2019-08-07T20:37:12Z")

</div>

Hello, I am using the processing java library as part of my project. Within the project, I like to load svg files and draw them on a pgraphics object. The svg files show icons with some white space around them. This wor…

---

## [How to center the alignment always](https://discourse.processing.org/t/how-to-center-the-alignment-always/13223)

<div class="topic-metadata">

**Author:** [@Hemanth](https://discourse.processing.org/u/Hemanth)\
**Replies:** 3\
**Last updated:** [August 7, 2019, 6:31pm UTC](https://discourse.processing.org/t/how-to-center-the-alignment-always/13223 "2019-08-07T18:31:28Z")

</div>

Hi, I was learning processing and I was trying something with the co ordinates, and I am having trouble in aligning to the center of the display window, for reference I have attached the video. In detailed explanation o…

---

## [Match depth image with color image](https://discourse.processing.org/t/match-depth-image-with-color-image/13161)

<div class="topic-metadata">

**Author:** [@Cai](https://discourse.processing.org/u/Cai)\
**Replies:** 1\
**Last updated:** [August 7, 2019, 1:45pm UTC](https://discourse.processing.org/t/match-depth-image-with-color-image/13161 "2019-08-07T13:45:33Z")

</div>

how do I minimize the error such that the color and displayed pixel match?

---

## [Converting my Processing sketch to a Processing.js sketch](https://discourse.processing.org/t/converting-my-processing-sketch-to-a-processing-js-sketch/13227)

<div class="topic-metadata">

**Author:** [@graysonh](https://discourse.processing.org/u/graysonh)\
**Replies:** 2\
**Last updated:** [August 7, 2019, 1:17pm UTC](https://discourse.processing.org/t/converting-my-processing-sketch-to-a-processing-js-sketch/13227 "2019-08-07T13:17:11Z")

</div>

Hi All, I have recently created an interactive version of a Daily Minimal graphic design and I really like the way it performs in Processing. I have been trying to put the sketch on OpenProcessing by using processing.js…

---

## [Indexing a for loop](https://discourse.processing.org/t/indexing-a-for-loop/13231)

<div class="topic-metadata">

**Author:** [@thedurf18](https://discourse.processing.org/u/thedurf18)\
**Replies:** 8\
**Last updated:** [August 7, 2019, 5:33am UTC](https://discourse.processing.org/t/indexing-a-for-loop/13231 "2019-08-07T05:33:12Z")

</div>

How can I have access to individual shapes that are contained within a for loop? Can I index the for loop and access the individual shapes through an array? I just received help with this code: PShape a; void setup() …

---

## [Using PShape in a for loop](https://discourse.processing.org/t/using-pshape-in-a-for-loop/13230)

<div class="topic-metadata">

**Author:** [@thedurf18](https://discourse.processing.org/u/thedurf18)\
**Replies:** 4\
**Last updated:** [August 7, 2019, 4:20am UTC](https://discourse.processing.org/t/using-pshape-in-a-for-loop/13230 "2019-08-07T04:20:39Z")

</div>

I’m trying to use the PShape I created and make multiple ones within a for loop, but I’m having some trouble. I’d appreciate any help. float variable; PShape a; void setup(){ size(1680,1005,P3D); background(0); } …

---

## [Load 16 bit per pixel PNG image](https://discourse.processing.org/t/load-16-bit-per-pixel-png-image/13221)

<div class="topic-metadata">

**Author:** [@Nikolai](https://discourse.processing.org/u/Nikolai)\
**Replies:** 1\
**Last updated:** [August 6, 2019, 11:57pm UTC](https://discourse.processing.org/t/load-16-bit-per-pixel-png-image/13221 "2019-08-06T23:57:48Z")

</div>

I need to load a 16 bit per pixel PNG image and save it as 8 bit (with some processing done on the channels). How can I do this in processing. Any image that I load only has 8 bit depth (even if I crank up the colorMode …

---

## [Making a trading card game](https://discourse.processing.org/t/making-a-trading-card-game/13219)

<div class="topic-metadata">

**Author:** [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Replies:** 0\
**Last updated:** [August 6, 2019, 9:37pm UTC](https://discourse.processing.org/t/making-a-trading-card-game/13219 "2019-08-06T21:37:02Z")

</div>

I’m trying to make a trading card game, but it keeps messing up. I got a table with an enemy to see if works then I created 2 creatures, one player, one enemy, so far they can walk towards each other & stop when they rea…

---

## [Saving to PDF while using the copy() function](https://discourse.processing.org/t/saving-to-pdf-while-using-the-copy-function/13201)

<div class="topic-metadata">

**Author:** [@daniel\_betts](https://discourse.processing.org/u/daniel_betts)\
**Replies:** 3\
**Last updated:** [August 6, 2019, 7:54pm UTC](https://discourse.processing.org/t/saving-to-pdf-while-using-the-copy-function/13201 "2019-08-06T19:54:39Z")

</div>

Hey, I’m have written a small code for a sort of text-warping tool using PGraphics, PFont, and the copy() function. I would like to output “Many Frames Into One File (With Screen Display)” as explained in the PDF librar…

---

## [Unicode and Smart quotes not being drawn properly](https://discourse.processing.org/t/unicode-and-smart-quotes-not-being-drawn-properly/13213)

<div class="topic-metadata">

**Author:** [@n055](https://discourse.processing.org/u/n055)\
**Replies:** 4\
**Last updated:** [August 6, 2019, 6:14pm UTC](https://discourse.processing.org/t/unicode-and-smart-quotes-not-being-drawn-properly/13213 "2019-08-06T18:14:27Z")

</div>

I am trying to display text entries by drawing them in my sketch. All of the text I will be using has quotation marks, and the source I am getting them from has them formatted as “curly” or “smart” quotes. However, when…

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

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