# Coding Questions

**URL:** https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=11

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

**Page:** 12

---

## [How to get smooth lines at an angle](https://discourse.processing.org/t/how-to-get-smooth-lines-at-an-angle/35767)

<div class="topic-metadata">

**Author:** [@GaryHomewood](https://discourse.processing.org/u/GaryHomewood)\
**Replies:** 1\
**Last updated:** [March 16, 2022, 2:46am UTC](https://discourse.processing.org/t/how-to-get-smooth-lines-at-an-angle/35767 "2022-03-16T02:46:33Z")

</div>

Just drawing lines, at some rotations they appear very blurry and pixelated. Is there anything I can do to make them sharper? Example here: https://editor.p5js.org/GaryHomewood/sketches/hBDmOiOHq

---

## [Getting x and y coordinates along a curve](https://discourse.processing.org/t/getting-x-and-y-coordinates-along-a-curve/35760)

<div class="topic-metadata">

**Author:** [@bringmeflowers](https://discourse.processing.org/u/bringmeflowers)\
**Replies:** 2\
**Last updated:** [March 15, 2022, 10:50am UTC](https://discourse.processing.org/t/getting-x-and-y-coordinates-along-a-curve/35760 "2022-03-15T10:50:05Z")

</div>

Aim: to get (x,y) coordinates for circles along an arc. Hi, I have been trying to plot circles along an arc and get their locations. I wonder if there is some theta stuff that I need to look into… this is the design t…

---

## [Horizontal gradient for line](https://discourse.processing.org/t/horizontal-gradient-for-line/35687)

<div class="topic-metadata">

**Author:** [@bringmeflowers](https://discourse.processing.org/u/bringmeflowers)\
**Replies:** 2\
**Last updated:** [March 15, 2022, 9:22am UTC](https://discourse.processing.org/t/horizontal-gradient-for-line/35687 "2022-03-15T09:22:39Z")

</div>

Hi, I have been trying out different ways to display horizontal gradients within lines, for example, do gradient for each circle and then put into lines. But it did not work. I just wonder if the effect is possible to …

---

## [Bresenham line generation not working? Making a line out of points](https://discourse.processing.org/t/bresenham-line-generation-not-working-making-a-line-out-of-points/35753)

<div class="topic-metadata">

**Author:** [@tinywitchdraws](https://discourse.processing.org/u/tinywitchdraws)\
**Replies:** 2\
**Last updated:** [March 15, 2022, 8:17am UTC](https://discourse.processing.org/t/bresenham-line-generation-not-working-making-a-line-out-of-points/35753 "2022-03-15T08:17:04Z")

</div>

I want to figure out how to make a line out of a series of points for implementation in another project in p5js, I heard that bresenham line generation was probably the best way to do this, however in the sketch I’ve imp…

---

## [Can shapes be limited by a border inside the canvas?](https://discourse.processing.org/t/can-shapes-be-limited-by-a-border-inside-the-canvas/35679)

<div class="topic-metadata">

**Author:** [@cottonchipper](https://discourse.processing.org/u/cottonchipper)\
**Replies:** 2\
**Last updated:** [March 13, 2022, 3:48pm UTC](https://discourse.processing.org/t/can-shapes-be-limited-by-a-border-inside-the-canvas/35679 "2022-03-13T15:48:53Z")

</div>

The following sketch sets up my question https://editor.p5js.org/cottonchipper/sketches/f7yKwh53v background(220); fill('red'); rect(0,0,200,200); rect(200,200,200,200); fill('white'); const y = (400)/2 + sin(…

---

## [Manually Coding B-Splines](https://discourse.processing.org/t/manually-coding-b-splines/35673)

<div class="topic-metadata">

**Author:** [@TheSynchronomicon](https://discourse.processing.org/u/TheSynchronomicon)\
**Replies:** 3\
**Last updated:** [March 11, 2022, 4:05pm UTC](https://discourse.processing.org/t/manually-coding-b-splines/35673 "2022-03-11T16:05:36Z")

</div>

So I’ve been trying to manually code a b-spline for a set of any number of user defined points, but I’ve hit a bit of a snag when it comes to the actually coding part of it. I first tested it with a specific knot vector …

---

## [Image filter gets stronger every loop - p5.js](https://discourse.processing.org/t/image-filter-gets-stronger-every-loop-p5-js/35641)

<div class="topic-metadata">

**Author:** [@emihardej](https://discourse.processing.org/u/emihardej)\
**Replies:** 2\
**Last updated:** [March 10, 2022, 9:55pm UTC](https://discourse.processing.org/t/image-filter-gets-stronger-every-loop-p5-js/35641 "2022-03-10T21:55:28Z")

</div>

I have made my own image filters sepia and blur. When the mouse is clicked on the original (left) image, it is meant to create a radial blur effect on the processed (right) image. However, after testing it I have found t…

---

## [Fill not overwriting the last fill](https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491)

<div class="topic-metadata">

**Author:** [@Bepishibe](https://discourse.processing.org/u/Bepishibe)\
**Replies:** 4\
**Last updated:** [March 10, 2022, 11:11am UTC](https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491 "2022-03-10T11:11:04Z")

</div>

so im trying to make a code for a school project where the german empire flag turns into the german flag when i drag on it. until the second ellipse(mouseX,mouseY,50,50); part, everything works fine, but in the if(200 \<=…

---

## [beginshape(TESS) how to uv map](https://discourse.processing.org/t/beginshape-tess-how-to-uv-map/32607)

<div class="topic-metadata">

**Author:** [@madwilson](https://discourse.processing.org/u/madwilson)\
**Replies:** 6\
**Last updated:** [March 9, 2022, 10:05pm UTC](https://discourse.processing.org/t/beginshape-tess-how-to-uv-map/32607 "2022-03-09T22:05:05Z")

</div>

I have been attempting to UVmap the beginshape(TESS) but I am assuming that I need to get access to the points created after ending the shape? which is why mapping to the points isn’t working. Any help or pointing me in…

---

## [createGraphics as background image](https://discourse.processing.org/t/creategraphics-as-background-image/35640)

<div class="topic-metadata">

**Author:** [@res56](https://discourse.processing.org/u/res56)\
**Replies:** 2\
**Last updated:** [March 9, 2022, 2:22pm UTC](https://discourse.processing.org/t/creategraphics-as-background-image/35640 "2022-03-09T14:22:28Z")

</div>

Hey frens, I generate a grid in setup-function and want to keep this as background- image in draw. Here some code: let img; var scl = 30; var cols, rows; function setup() { createCanvas(400, 400); img = c…

---

## [P5js \[Violation\] 'requestAnimationFrame' handler took 75ms](https://discourse.processing.org/t/p5js-violation-requestanimationframe-handler-took-75ms/31976)

<div class="topic-metadata">

**Author:** [@suecouzq](https://discourse.processing.org/u/suecouzq)\
**Replies:** 2\
**Last updated:** [March 8, 2022, 10:23pm UTC](https://discourse.processing.org/t/p5js-violation-requestanimationframe-handler-took-75ms/31976 "2022-03-08T22:23:07Z")

</div>

I am getting this ‘requestAnimationFrame’ error with this code. I guess there’s something with the for loop that causes the problem but I can’t figure an alternative way of getting the same visual result. Any idea? let …

---

## [Constricting shape movement in p5js](https://discourse.processing.org/t/constricting-shape-movement-in-p5js/35361)

<div class="topic-metadata">

**Author:** [@rorywilliams](https://discourse.processing.org/u/rorywilliams)\
**Replies:** 1\
**Last updated:** [March 8, 2022, 9:41pm UTC](https://discourse.processing.org/t/constricting-shape-movement-in-p5js/35361 "2022-03-08T21:41:39Z")

</div>

Hi, I’m a beginner with p5js and I’ve run into some trouble with some code I’m writing. I have three circles of decreasing size, with the smallest and middle circles mapped to mouseX and mouseY. My issue is that I want t…

---

## [Having trouble with colorMode and WEBGL on OpenProcessing](https://discourse.processing.org/t/having-trouble-with-colormode-and-webgl-on-openprocessing/35531)

<div class="topic-metadata">

**Author:** [@brackish](https://discourse.processing.org/u/brackish)\
**Replies:** 2\
**Last updated:** [March 3, 2022, 12:00pm UTC](https://discourse.processing.org/t/having-trouble-with-colormode-and-webgl-on-openprocessing/35531 "2022-03-03T12:00:44Z")

</div>

I’m trying to build this sketch on openprocessing: it’s a fork of someone else’s sphere mapping sketch, which uses WEBGL. i’m trying to apply a lofi text mode filter over the top. i’ve copied some text mode code tha…

---

## [ASCII Video with GIF](https://discourse.processing.org/t/ascii-video-with-gif/35476)

<div class="topic-metadata">

**Author:** [@JulienBgr](https://discourse.processing.org/u/JulienBgr)\
**Replies:** 0\
**Last updated:** [February 28, 2022, 9:01am UTC](https://discourse.processing.org/t/ascii-video-with-gif/35476 "2022-02-28T09:01:47Z")

</div>

Hey Guys ! I just saw a video on YouTube for ASCII Video (ASCII Video (Coding Challenge 166) by The Coding Train) and tried this for myself. Furthermore I want to include a GIF, but have some troubles with the implementa…

---

## [textureWrap() is not setting after called a second time](https://discourse.processing.org/t/texturewrap-is-not-setting-after-called-a-second-time/35474)

<div class="topic-metadata">

**Author:** [@graph100](https://discourse.processing.org/u/graph100)\
**Replies:** 1\
**Last updated:** [February 28, 2022, 12:59pm UTC](https://discourse.processing.org/t/texturewrap-is-not-setting-after-called-a-second-time/35474 "2022-02-28T12:59:09Z")

</div>

I’m working on a program where some of the models need to have repeated textures and others do not require that. Where I am trying to repeat my textures I call textureWrap(REPEAT), and just to be sure I’ve put textureWra…

---

## [Creating random shapes within the limits](https://discourse.processing.org/t/creating-random-shapes-within-the-limits/35438)

<div class="topic-metadata">

**Author:** [@callenk](https://discourse.processing.org/u/callenk)\
**Replies:** 6\
**Last updated:** [February 27, 2022, 1:00pm UTC](https://discourse.processing.org/t/creating-random-shapes-within-the-limits/35438 "2022-02-27T13:00:07Z")

</div>

Hi, I am trying to draw some shapes to resemble a face, I have arrays that holds the certain x, y points for each part of a human face like eyes, jaw,nose etc. What is the best way to go about this, using arc, vertex? T…

---

## [Convert p5js to Processing](https://discourse.processing.org/t/convert-p5js-to-processing/29893)

<div class="topic-metadata">

**Author:** [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Replies:** 11\
**Last updated:** [February 26, 2022, 1:58am UTC](https://discourse.processing.org/t/convert-p5js-to-processing/29893 "2022-02-26T01:58:30Z")

</div>

could anyone help me converting this code into Processing please? thanks

---

## [Cant call from an Array on createGraphics canvas](https://discourse.processing.org/t/cant-call-from-an-array-on-creategraphics-canvas/35434)

<div class="topic-metadata">

**Author:** [@chriscorey](https://discourse.processing.org/u/chriscorey)\
**Replies:** 4\
**Last updated:** [February 25, 2022, 8:19pm UTC](https://discourse.processing.org/t/cant-call-from-an-array-on-creategraphics-canvas/35434 "2022-02-25T20:19:23Z")

</div>

Project Goal: I’d like to create a simple drawing program that randomly cycles through an array of shapes which the user has to place one at a time. I have a simple version built but when I try to draw something from an …

---

## [Texture as data in shader has odd behavior](https://discourse.processing.org/t/texture-as-data-in-shader-has-odd-behavior/33197)

<div class="topic-metadata">

**Author:** [@altitudinem](https://discourse.processing.org/u/altitudinem)\
**Replies:** 18\
**Last updated:** [February 23, 2022, 8:20pm UTC](https://discourse.processing.org/t/texture-as-data-in-shader-has-odd-behavior/33197 "2022-02-23T20:20:17Z")

</div>

Dear community, I’m learning how to use a shader, especially within p5js. I’ve learned from this post how to pass a set of data as a texture and use it in the shader program. I appreciate that @hamoid and @myselfhims…

---

## [Testing equality of vectors in a 2 dimensional array](https://discourse.processing.org/t/testing-equality-of-vectors-in-a-2-dimensional-array/35389)

<div class="topic-metadata">

**Author:** [@arathorn76](https://discourse.processing.org/u/arathorn76)\
**Replies:** 5\
**Last updated:** [February 23, 2022, 7:23pm UTC](https://discourse.processing.org/t/testing-equality-of-vectors-in-a-2-dimensional-array/35389 "2022-02-23T19:23:53Z")

</div>

Hello together, I have a problem testing equality of one line of a 2D array against a possible new line. My goal is to add a new line only if a line with the same elements does not yet exist. To achieve this I wrote t…

---

## [Abort loadSound()](https://discourse.processing.org/t/abort-loadsound/35377)

<div class="topic-metadata">

**Author:** [@Lerudan](https://discourse.processing.org/u/Lerudan)\
**Replies:** 0\
**Last updated:** [February 22, 2022, 10:02am UTC](https://discourse.processing.org/t/abort-loadsound/35377 "2022-02-22T10:02:20Z")

</div>

I’m building a little applet with audio-files. Each level starts with loading an audiofile. I also use the history api of the browser, to give each level a usable URL. Now if a user changes the history state, while loa…

---

## [GL.getExtension ('OES\_standard\_derivatives');](https://discourse.processing.org/t/gl-getextension-oes-standard-derivatives/29854)

<div class="topic-metadata">

**Author:** [@BigBigRed](https://discourse.processing.org/u/BigBigRed)\
**Replies:** 6\
**Last updated:** [February 22, 2022, 3:11am UTC](https://discourse.processing.org/t/gl-getextension-oes-standard-derivatives/29854 "2022-02-22T03:11:19Z")

</div>

I am trying to work with some code that someone else did. my p5js sketch is hanging/ crashing at the line ‘vec3 normal = vec3(-dFdx(f), -dFdy(f), 0.5) + 0.5;’. My diagnostic efforts lead me to think that the call to ‘dF…

---

## [Initializing multiple timers within the draw loop ()](https://discourse.processing.org/t/initializing-multiple-timers-within-the-draw-loop/35335)

<div class="topic-metadata">

**Author:** [@basicvisual](https://discourse.processing.org/u/basicvisual)\
**Replies:** 10\
**Last updated:** [February 21, 2022, 9:45pm UTC](https://discourse.processing.org/t/initializing-multiple-timers-within-the-draw-loop/35335 "2022-02-21T21:45:45Z")

</div>

Hello , I am trying to understand the concept of timers in p5js. If i understand , there is no way to initialize two timers in the draw loop. I was using the millis function to take the note of time. For example in the …

---

## [createGraphics combined with text and second()](https://discourse.processing.org/t/creategraphics-combined-with-text-and-second/35293)

<div class="topic-metadata">

**Author:** [@goldorak](https://discourse.processing.org/u/goldorak)\
**Replies:** 19\
**Last updated:** [February 20, 2022, 12:50am UTC](https://discourse.processing.org/t/creategraphics-combined-with-text-and-second/35293 "2022-02-20T00:50:11Z")

</div>

Hi, For debugging purposes, I’d like to display the time value in my canvas. To do so, I’d like to use createGraphics combined with text(); Unfortunately it looks like I can’t send the value from second() to my pg. It…

---

## [How do I create a table inside p5 space?](https://discourse.processing.org/t/how-do-i-create-a-table-inside-p5-space/35283)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 11\
**Last updated:** [February 19, 2022, 4:15pm UTC](https://discourse.processing.org/t/how-do-i-create-a-table-inside-p5-space/35283 "2022-02-19T16:15:13Z")

</div>

How do I create a table inside p5 space? link : https://codepen.io/anon/pen/bNJeLO Like the picture above, I want to create a slide table. Is there any way to make a slide table in p5 space?

---

## [ClickThrough\_mousePressed()](https://discourse.processing.org/t/clickthrough-mousepressed/35277)

<div class="topic-metadata">

**Author:** [@svan](https://discourse.processing.org/u/svan)\
**Replies:** 2\
**Last updated:** [February 19, 2022, 2:33am UTC](https://discourse.processing.org/t/clickthrough-mousepressed/35277 "2022-02-19T02:33:27Z")

</div>

The following demo illustrates ‘click through’; depending on where you click in the green rectangle, mousePressed() will report either two or three rectangles since they are overlapped. Is there a way to trap only the c…

---

## [Converting sketch from p5.js to Processing (Image art: Messy Curve Draw)](https://discourse.processing.org/t/converting-sketch-from-p5-js-to-processing-image-art-messy-curve-draw/26969)

<div class="topic-metadata">

**Author:** [@Marinus](https://discourse.processing.org/u/Marinus)\
**Replies:** 8\
**Last updated:** [February 18, 2022, 2:17pm UTC](https://discourse.processing.org/t/converting-sketch-from-p5-js-to-processing-image-art-messy-curve-draw/26969 "2022-02-18T14:17:55Z")

</div>

Hi, I’ve found a beautiful starting point for what I am intending to achieve: drawing a portrait of a face with curved lines and exporting it to SVG. However, it’s written in p5.js and the p5.js version doesn’t support …

---

## [Calling .selected(value) multiple times on a radio button does not change the selected option](https://discourse.processing.org/t/calling-selected-value-multiple-times-on-a-radio-button-does-not-change-the-selected-option/35194)

<div class="topic-metadata">

**Author:** [@fabiopettinati](https://discourse.processing.org/u/fabiopettinati)\
**Replies:** 6\
**Last updated:** [February 17, 2022, 8:47pm UTC](https://discourse.processing.org/t/calling-selected-value-multiple-times-on-a-radio-button-does-not-change-the-selected-option/35194 "2022-02-17T20:47:35Z")

</div>

I have a sketch where I create a radio button with 4 options, the last one being selected upon creation inside the setup() function. When the sketch runs and I resize the window, I want to force selecting the last optio…

---

## [How to use mask with animation loop?](https://discourse.processing.org/t/how-to-use-mask-with-animation-loop/35244)

<div class="topic-metadata">

**Author:** [@ongo](https://discourse.processing.org/u/ongo)\
**Replies:** 0\
**Last updated:** [February 17, 2022, 5:03pm UTC](https://discourse.processing.org/t/how-to-use-mask-with-animation-loop/35244 "2022-02-17T17:03:59Z")

</div>

Code used to attempt this so far: I want to find a way to be able to slightly edit a mask on every loop to create an animated effect. Such as on each loop increasing the Y coordinate of where the ellipse is drawn over …

---

## [Cropping an image buffer on transparency?](https://discourse.processing.org/t/cropping-an-image-buffer-on-transparency/35125)

<div class="topic-metadata">

**Author:** [@xeronimo](https://discourse.processing.org/u/xeronimo)\
**Replies:** 2\
**Last updated:** [February 16, 2022, 12:38pm UTC](https://discourse.processing.org/t/cropping-an-image-buffer-on-transparency/35125 "2022-02-16T12:38:16Z")

</div>

I’d like to crop/copy an image buffer in #p5js so that only the non-transparent part is kept/copied … any ideas how to do that (quickly)!? Thanks!

[Previous page](https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=10)

[Next page](https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=12)
