# Coding Questions

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

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

**Page:** 34

---

## [Video help please - no content type found for .webm](https://discourse.processing.org/t/video-help-please-no-content-type-found-for-webm/20234)

<div class="topic-metadata">

**Author:** [@samthetinkerer](https://discourse.processing.org/u/samthetinkerer)\
**Replies:** 1\
**Last updated:** [April 30, 2020, 7:10am UTC](https://discourse.processing.org/t/video-help-please-no-content-type-found-for-webm/20234 "2020-04-30T07:10:28Z")

</div>

I am writing an interactive video animation with a series of video clips in .webm format. It runs correctly but the console log shows the error: no content type found for .webm. I have tried looking at MIME types but hav…

---

## [Nested canvases?](https://discourse.processing.org/t/nested-canvases/20033)

<div class="topic-metadata">

**Author:** [@Yom](https://discourse.processing.org/u/Yom)\
**Replies:** 5\
**Last updated:** [April 27, 2020, 10:47pm UTC](https://discourse.processing.org/t/nested-canvases/20033 "2020-04-27T22:47:29Z")

</div>

Hello, I’m new to p5.js, javascript, etc… I would like to have a canvas inside another canvas. Here is my current code, it works but is it a bad idea ? And if so, why ? const sketch1 = p5 =\> { p5.setup = () =\> { …

---

## [Variables from php to j5](https://discourse.processing.org/t/variables-from-php-to-j5/20153)

<div class="topic-metadata">

**Author:** [@goorny](https://discourse.processing.org/u/goorny)\
**Replies:** 2\
**Last updated:** [April 25, 2020, 11:51pm UTC](https://discourse.processing.org/t/variables-from-php-to-j5/20153 "2020-04-25T23:51:05Z")

</div>

Hello. I start" programing" in p5 few weeks ago. Last week try figure out one problem by reading refference , look tons from YT, and searching at forums. Small example: index.php \<?php $ble=blebleble ?\> index.js …

---

## [Exceptions in random()](https://discourse.processing.org/t/exceptions-in-random/20187)

<div class="topic-metadata">

**Author:** [@Rahul](https://discourse.processing.org/u/Rahul)\
**Replies:** 2\
**Last updated:** [April 27, 2020, 1:58am UTC](https://discourse.processing.org/t/exceptions-in-random/20187 "2020-04-27T01:58:39Z")

</div>

Hello. Recently, I’ve been working on a sketch in which I need to line up circles in a random order. Basically, I have an array with all the x-coordinates of the circles, and I have a for loop in setup to display enough …

---

## [Sequenced animation with state](https://discourse.processing.org/t/sequenced-animation-with-state/20140)

<div class="topic-metadata">

**Author:** [@alexalex25](https://discourse.processing.org/u/alexalex25)\
**Replies:** 2\
**Last updated:** [April 26, 2020, 1:48pm UTC](https://discourse.processing.org/t/sequenced-animation-with-state/20140 "2020-04-26T13:48:52Z")

</div>

Hi, I’m trying to do a simple animation in sequence: at start of sketch : a square moves to the right 100px. after it finishes that step, it waits 2 seconds after it finishes that step it goes down for 100px. after tha…

---

## [Clicking on and moving rotated shapes](https://discourse.processing.org/t/clicking-on-and-moving-rotated-shapes/20177)

<div class="topic-metadata">

**Author:** [@dansdnadesigns](https://discourse.processing.org/u/dansdnadesigns)\
**Replies:** 0\
**Last updated:** [April 26, 2020, 1:40pm UTC](https://discourse.processing.org/t/clicking-on-and-moving-rotated-shapes/20177 "2020-04-26T13:40:00Z")

</div>

Hello. I have made the following sketch which draws rod shapes using a class at random angles on the canvas. I want the rods to change color when the mouse is rolled over and when the mouse is pressed inside the rods I w…

---

## [Unable to vizualize a sorted array while implementing mergesort](https://discourse.processing.org/t/unable-to-vizualize-a-sorted-array-while-implementing-mergesort/20122)

<div class="topic-metadata">

**Author:** [@Suraaj](https://discourse.processing.org/u/Suraaj)\
**Replies:** 4\
**Last updated:** [April 26, 2020, 6:50am UTC](https://discourse.processing.org/t/unable-to-vizualize-a-sorted-array-while-implementing-mergesort/20122 "2020-04-26T06:50:50Z")

</div>

I tried to implement a mergesort algorithm but the array isn’t getting sorted for some reason.The expected output is a sorted array of lines displayed on the browser window. Here is my code var values = \[\] function se…

---

## [Problems using getItem and storeItem - any suggestions](https://discourse.processing.org/t/problems-using-getitem-and-storeitem-any-suggestions/20108)

<div class="topic-metadata">

**Author:** [@RetProf](https://discourse.processing.org/u/RetProf)\
**Replies:** 2\
**Last updated:** [April 24, 2020, 8:54pm UTC](https://discourse.processing.org/t/problems-using-getitem-and-storeitem-any-suggestions/20108 "2020-04-24T20:54:27Z")

</div>

I am attempting to develop a sketch that will collect information and store it for use in subsequent reloads of the sketch. Given the information related to the “storeInfo” and “getInfo” operations I was under the impres…

---

## [How to add text inside circle or any other shapes in p5.js](https://discourse.processing.org/t/how-to-add-text-inside-circle-or-any-other-shapes-in-p5-js/20092)

<div class="topic-metadata">

**Author:** [@pravandan](https://discourse.processing.org/u/pravandan)\
**Replies:** 2\
**Last updated:** [April 24, 2020, 1:55pm UTC](https://discourse.processing.org/t/how-to-add-text-inside-circle-or-any-other-shapes-in-p5-js/20092 "2020-04-24T13:55:35Z")

</div>

I have the following code and I want to display different text in different circles. How to achieve that ? // Uses P5.js for canvas creation and drawing function setup() { var circles = \[\], circle = {}, ov…

---

## [Run a javascript function from p5.js or read a variable in the DOM](https://discourse.processing.org/t/run-a-javascript-function-from-p5-js-or-read-a-variable-in-the-dom/20090)

<div class="topic-metadata">

**Author:** [@paolon](https://discourse.processing.org/u/paolon)\
**Replies:** 3\
**Last updated:** [April 24, 2020, 1:55pm UTC](https://discourse.processing.org/t/run-a-javascript-function-from-p5-js-or-read-a-variable-in-the-dom/20090 "2020-04-24T13:55:07Z")

</div>

Hi everyone, it’s a pleasure to join this community! I have a problem that I think is quite simple for you but I have been banging my head for days for which I ask for your help. I want to make a kind of universal watch…

---

## [Compare Color Variables](https://discourse.processing.org/t/compare-color-variables/17238)

<div class="topic-metadata">

**Author:** [@nciprian](https://discourse.processing.org/u/nciprian)\
**Replies:** 5\
**Last updated:** [April 22, 2020, 11:43pm UTC](https://discourse.processing.org/t/compare-color-variables/17238 "2020-04-22T23:43:17Z")

</div>

Hello, Is there a way to compare to color variable? let inside = color(204, 102, 0); let middle = color(204, 102, 0); i need to compare this two variables, but none of the usual ways work. (inside == middle)

---

## [Signal Averaging P5JS](https://discourse.processing.org/t/signal-averaging-p5js/17735)

<div class="topic-metadata">

**Author:** [@black](https://discourse.processing.org/u/black)\
**Replies:** 3\
**Last updated:** [April 22, 2020, 5:01pm UTC](https://discourse.processing.org/t/signal-averaging-p5js/17735 "2020-04-22T17:01:21Z")

</div>

So I was writing the signal averaging code on a random generated data. Steps I did - Generating a signal to simulated Real time data Signal = random data (-10,10) + periodic data (50,100 ) after every 100 tx Taking sa…

---

## [Enabling face detection p5.js camera access in chrome extension](https://discourse.processing.org/t/enabling-face-detection-p5-js-camera-access-in-chrome-extension/20034)

<div class="topic-metadata">

**Author:** [@yuinjann](https://discourse.processing.org/u/yuinjann)\
**Replies:** 0\
**Last updated:** [April 22, 2020, 2:00pm UTC](https://discourse.processing.org/t/enabling-face-detection-p5-js-camera-access-in-chrome-extension/20034 "2020-04-22T14:00:41Z")

</div>

Hiya! I am trying to make a pop up chrome extension using this face detector example made with p5.js from https://github.com/stc/face-tracking-p5js/tree/master/008\_emotion example. Basically, I want to count the number …

---

## [Image Slice Tool – Output Canvas Resolution Issue](https://discourse.processing.org/t/image-slice-tool-output-canvas-resolution-issue/19997)

<div class="topic-metadata">

**Author:** [@matejvojtus](https://discourse.processing.org/u/matejvojtus)\
**Replies:** 1\
**Last updated:** [April 21, 2020, 11:56pm UTC](https://discourse.processing.org/t/image-slice-tool-output-canvas-resolution-issue/19997 "2020-04-21T23:56:49Z")

</div>

Hi everyone, I am quite new to p5js world and I am trying to create an Image slicing tool. The code gets me the wanted result – sliced input image but it seems that it doesn’t retain the intial resolution of the image…

---

## [How do i make doubleClicked() run without call existing mousePressed()? (p5.js)](https://discourse.processing.org/t/how-do-i-make-doubleclicked-run-without-call-existing-mousepressed-p5-js/19982)

<div class="topic-metadata">

**Author:** [@Royjan](https://discourse.processing.org/u/Royjan)\
**Replies:** 5\
**Last updated:** [April 21, 2020, 5:55pm UTC](https://discourse.processing.org/t/how-do-i-make-doubleclicked-run-without-call-existing-mousepressed-p5-js/19982 "2020-04-21T17:55:13Z")

</div>

Hello everybody, So i have a problem to call doubleClicked() function without calling existing mousePressed() function. Can please anyone give me a trick for that one? Thanks!!

---

## [How to get the file path of a file dropped in the webpage](https://discourse.processing.org/t/how-to-get-the-file-path-of-a-file-dropped-in-the-webpage/19870)

<div class="topic-metadata">

**Author:** [@CodingIsLife](https://discourse.processing.org/u/CodingIsLife)\
**Replies:** 3\
**Last updated:** [April 21, 2020, 1:38am UTC](https://discourse.processing.org/t/how-to-get-the-file-path-of-a-file-dropped-in-the-webpage/19870 "2020-04-21T01:38:59Z")

</div>

I was trying to make a drag and drop just like this video by Daniel Shiffman https://www.youtube.com/watch?v=o4UmGrPst\_c&t=317s But I was wandering if I could get the file path of the dropped file and thus download the …

---

## [Get image from webcam capture](https://discourse.processing.org/t/get-image-from-webcam-capture/19381)

<div class="topic-metadata">

**Author:** [@SenseiJae](https://discourse.processing.org/u/SenseiJae)\
**Replies:** 2\
**Last updated:** [April 19, 2020, 11:18pm UTC](https://discourse.processing.org/t/get-image-from-webcam-capture/19381 "2020-04-19T23:18:24Z")

</div>

I’m trying to follow “coding train’s” example of capturing images from a webcam for a “photo booth”. It was working great up until I go to the for loop to capture the images. When I use “get()” on the createCapture() o…

---

## ["Get" as color detector?](https://discourse.processing.org/t/get-as-color-detector/19912)

<div class="topic-metadata">

**Author:** [@mnoble](https://discourse.processing.org/u/mnoble)\
**Replies:** 13\
**Last updated:** [April 19, 2020, 8:41pm UTC](https://discourse.processing.org/t/get-as-color-detector/19912 "2020-04-19T20:41:48Z")

</div>

Hello Forum :slight\_smile: On Processing, I love this program for detecting colors: color c; void setup (){ size (200,200); } void draw() { background (0); fill (255); rect (0,0,100,200); c = get (mouseX,m…

---

## [Print() Causes Animation Lagging - Are there fixes? What else causes lags?](https://discourse.processing.org/t/print-causes-animation-lagging-are-there-fixes-what-else-causes-lags/19702)

<div class="topic-metadata">

**Author:** [@mnoble](https://discourse.processing.org/u/mnoble)\
**Replies:** 3\
**Last updated:** [April 18, 2020, 10:46pm UTC](https://discourse.processing.org/t/print-causes-animation-lagging-are-there-fixes-what-else-causes-lags/19702 "2020-04-18T22:46:58Z")

</div>

Hello Forum, I am in the processing of shifting from Processing to p5Js for my high school class that is now online starting Monday. We love to use print() to learn but I noticed that it causes severe lag for animations…

---

## [Inherit/Use p5.Vector methods in NodeJS](https://discourse.processing.org/t/inherit-use-p5-vector-methods-in-nodejs/19909)

<div class="topic-metadata">

**Author:** [@cake](https://discourse.processing.org/u/cake)\
**Replies:** 4\
**Last updated:** [April 18, 2020, 10:34pm UTC](https://discourse.processing.org/t/inherit-use-p5-vector-methods-in-nodejs/19909 "2020-04-18T22:34:38Z")

</div>

Hello! I’d like to inherit & use p5.Vector & its methods in a class I’m writing. / Use p5.Vector without a window. This is backend code, I’ve seen that p5 cannot ‘run’ without a ‘window’ object. As it gives me ‘window’ …

---

## [Text appears in different positions](https://discourse.processing.org/t/text-appears-in-different-positions/19720)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 1\
**Last updated:** [April 18, 2020, 6:51pm UTC](https://discourse.processing.org/t/text-appears-in-different-positions/19720 "2020-04-18T18:51:27Z")

</div>

I had an earlier problem where buttons didn’t stay where I wanted on the canvas. I managed to resolve that problem. I should say resolved somewhat because the position is slightly different in Chrome compared to Mozilla. …

---

## [TypeError when sketch hosted on a webserver but not when on my computer?](https://discourse.processing.org/t/typeerror-when-sketch-hosted-on-a-webserver-but-not-when-on-my-computer/19762)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 9\
**Last updated:** [April 16, 2020, 2:04am UTC](https://discourse.processing.org/t/typeerror-when-sketch-hosted-on-a-webserver-but-not-when-on-my-computer/19762 "2020-04-16T02:04:27Z")

</div>

So my p5js script script runs fine on the web editor and also when I run it in Atom but when I upload it to my web host and access the page from there, I get: TypeError: cnv is undefined or TypeError: cannot read prop…

---

## [Can 2 buttons call the same function and detect which button was pressed?](https://discourse.processing.org/t/can-2-buttons-call-the-same-function-and-detect-which-button-was-pressed/19654)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 2\
**Last updated:** [April 11, 2020, 4:16pm UTC](https://discourse.processing.org/t/can-2-buttons-call-the-same-function-and-detect-which-button-was-pressed/19654 "2020-04-11T16:16:59Z")

</div>

I have 2 images on a canvas and each image has it’s own button. When the first button is pressed, the first image is selected. When the second button is pressed, the second image is selected. button1 = createButton("S…

---

## [Making a shape face the mouse](https://discourse.processing.org/t/making-a-shape-face-the-mouse/19735)

<div class="topic-metadata">

**Author:** [@poppyseeds](https://discourse.processing.org/u/poppyseeds)\
**Replies:** 3\
**Last updated:** [April 14, 2020, 10:30am UTC](https://discourse.processing.org/t/making-a-shape-face-the-mouse/19735 "2020-04-14T10:30:15Z")

</div>

In this sketch, I have two ellipses that look like a fish. It follows the position of the invisible cursor. Along with moving as it currently is, I want to make the fish face the cursor at all times which means if i move…

---

## [Changing target positions of vehicles](https://discourse.processing.org/t/changing-target-positions-of-vehicles/19738)

<div class="topic-metadata">

**Author:** [@poppyseeds](https://discourse.processing.org/u/poppyseeds)\
**Replies:** 4\
**Last updated:** [April 14, 2020, 9:42am UTC](https://discourse.processing.org/t/changing-target-positions-of-vehicles/19738 "2020-04-14T09:42:26Z")

</div>

In this project, I have used the text to point function to create vehicles which exhibit the seek, arrive and flee behaviours. Currently, the vehicles form the word ‘SWIMMY’ which is the start and target position. On cli…

---

## [How can i get a line to move in a curve to a specific region on the canvas?](https://discourse.processing.org/t/how-can-i-get-a-line-to-move-in-a-curve-to-a-specific-region-on-the-canvas/19656)

<div class="topic-metadata">

**Author:** [@yasinyer](https://discourse.processing.org/u/yasinyer)\
**Replies:** 3\
**Last updated:** [April 13, 2020, 1:04pm UTC](https://discourse.processing.org/t/how-can-i-get-a-line-to-move-in-a-curve-to-a-specific-region-on-the-canvas/19656 "2020-04-13T13:04:29Z")

</div>

Hi guys! I’m a newbie in programming and could really use the help of you experts for my bachelor project. What I already have is a line that moves in a curve when turning, based on the arrowkeys. This line is only abl…

---

## [Buttons on my canvas move as I resize or maximize the browser window. How do I stop this?](https://discourse.processing.org/t/buttons-on-my-canvas-move-as-i-resize-or-maximize-the-browser-window-how-do-i-stop-this/19687)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 5\
**Last updated:** [April 12, 2020, 8:54pm UTC](https://discourse.processing.org/t/buttons-on-my-canvas-move-as-i-resize-or-maximize-the-browser-window-how-do-i-stop-this/19687 "2020-04-12T20:54:52Z")

</div>

The buttons that I’ve added to my sketch are not really positioned on my canvas. I think they’re actually floating. I need them to be in fixed spots on my canvas. How do I accomplish this? I think my centerCanvas() func…

---

## [How much memory does a p5.Vector variable take up compared to an integer variable?](https://discourse.processing.org/t/how-much-memory-does-a-p5-vector-variable-take-up-compared-to-an-integer-variable/19681)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 1\
**Last updated:** [April 12, 2020, 12:42am UTC](https://discourse.processing.org/t/how-much-memory-does-a-p5-vector-variable-take-up-compared-to-an-integer-variable/19681 "2020-04-12T00:42:19Z")

</div>

I’m writing something that involves image manipulation. I decided to use an array of p5.Vectors because I could store the x and y coordinates of pixels more easily. I could just as easily create 2 integer arrays (coordin…

---

## [Unable to position my object at a specific location](https://discourse.processing.org/t/unable-to-position-my-object-at-a-specific-location/19646)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 2\
**Last updated:** [April 11, 2020, 11:02pm UTC](https://discourse.processing.org/t/unable-to-position-my-object-at-a-specific-location/19646 "2020-04-11T23:02:56Z")

</div>

I’ve created an object myCanvas but I’m unable to position it on the main canvas. I think it just gets added to 0,0. I would like to put it at a specific location on the canvas that’s created in setup(). So maybe at 100,…

---

## [How do I save an image that has been shrunk using the image function?](https://discourse.processing.org/t/how-do-i-save-an-image-that-has-been-shrunk-using-the-image-function/19651)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 1\
**Last updated:** [April 11, 2020, 4:49am UTC](https://discourse.processing.org/t/how-do-i-save-an-image-that-has-been-shrunk-using-the-image-function/19651 "2020-04-11T04:49:50Z")

</div>

I’m using image(photo1, xpos, ypos, newWidth, newHeight) to shrink a large image. My question is, how do I save that new shrunken image into a variable so that I can manipulate it further? I want to be able to modify th…

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

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