3,163 questions
0
votes
1
answer
124
views
How can I import an external javascript library (from a CDN) for a website and still have types in my editor?
I'm working in astro which uses vite as its bundler, don't know if that helps.
So basically I have p5.js as a dependency for a sketch I demonstrate on my portfolio site, using the library from npm, ...
1
vote
1
answer
75
views
Using P5 createRadio() in a class and having two objects of that class leads to radio buttons not functioning independently [closed]
When I use the createRadio() function from the p5js library in a function constructor and create multiple objects of that class, the radio buttons act differently, when I select an option in a radio ...
-2
votes
1
answer
84
views
Why is my p5.play.js not working on github but working on VScode? [closed]
Whenever I try to deploy my p5play code on GitHub Pages, it just shows a blank screen. What can I do to resolve this issue? It works perfectly on VS Code. Specifically, the page has a white background....
1
vote
0
answers
57
views
FrameRate function will not return accurate frameRate P5JS
I have this piece of code:
var framerate = 120;
function setup() {
createCanvas(1920, 1080);
frameRate(framerate);
}
function draw() {
clear();
textSize(13);
text(frameRate(), 20, 20);
}
&...
2
votes
1
answer
85
views
webgl canvas with shader not filling screen
how do I fill the full canvas with the full webgl shader layer? The canvas is filling the full window width and height, but the webgl shader layer is stuck to the top right quadrant of the screen at ...
1
vote
0
answers
45
views
Jitter problem with differential line growth
I'm trying to create a smooth animation using differential line growth.
I can have a snake on the screen grow and fill the space which I want.
It's made up out of a number of nodes with two forces ...
3
votes
1
answer
83
views
p5js filter shader causing graphics object transparency to turn black
I'm attempting to simulate wind blowing across plants on a p5js sketch and came across a lovely fragment shader that does pretty much what I want (// https://github.com/GameMakerDiscord/wind-shader
).
...
0
votes
1
answer
54
views
p5.js Cannot convert undefined or null to object [closed]
I am trying to make a grid for a game, and I set up the grid, but when I use a for loop to display all of the cells it gives me an error - Uncaught TypeError: Cannot convert undefined or null to ...
0
votes
0
answers
32
views
AfterRendered Hook in Paged.JS [duplicate]
I am using paged.js together with Kirby CMS and p5.js. And it is working pretty well.
My Problem: I need to get informed when paged.js is finished rendering the page layout. There should be a hook for ...
1
vote
1
answer
59
views
Player movement with split screen viewports using p5
I am trying to make a program where there are two different screens that are centered on different players. I am using createGraphics() to try and achieve this. They render, but the screens aren't ...
0
votes
1
answer
110
views
p5js move in camera direction
I am trying to make a first-person player controller. I can make the camera pan/tilt on mouse movement, but I am having problems trying to make the player move in the direction the camera is facing. ...
1
vote
1
answer
79
views
How do I gain access to the array in a method?
I have created this program that checks the collisions of balls as they move in random directions. Each ball has life points, that decrease with each collision. I want my program to print out a ...
1
vote
1
answer
69
views
p5js rotating a camera around a point with mouse
I'm trying to make a third person player controller in p5js using WEBGL, and I can't figure out how to make the camera rotate around a point. I've tried using rotate, but it just makes the cube (...
2
votes
1
answer
62
views
P5.JS createSelect() not changing selected option when called in draw function
I'm working on a class project to build a drawing app using p5.js. One of my features is a tool to draw different shapes and includes using a dropdown menu to select a shape to draw to the canvas. I'm ...
1
vote
1
answer
74
views
How can I change the stroke within BuildGeometry?
When using buildGeometry (in p5.js's webgl mode), the fill color can change inside the function while the stroke color cannot. Without this all shapes inside the function must have the same stroke ...
0
votes
1
answer
63
views
Looking for a solution to make video autoplay work with p5.js on Firefox for Android, while it works in other browsers
I’m trying to get p5.js to autoplay video on Firefox Android, but I haven’t found a solution yet. Here’s a CodePen link demonstrating the issue:
https://codepen.io/vincent-vandercruyssen-kunstkaai/pen/...
2
votes
2
answers
136
views
Why are my songs showing up as undefined?
Working in p5.js on a class assignment. We have to make a music player. I found a tutorial in the site, but despite copying the code near-exactly (only altering so as to implement multiple songs), I ...
0
votes
0
answers
49
views
Webcam footage stopping when mouseClicked to take an image of video
I'm learning about image processing in class and I need to be able to take a screenshot of the webcam video that I'm displaying to the screen currently using p5.js. The problem is when I click the ...
0
votes
0
answers
57
views
Pixels[] in p5.js doesn't return proper color values upon canvas resize
I'm working on a generative art project and seem to be running into an issue with the pixels function. Part of the artwork algorithm involves drawing circles (i.e., trees) in certain parts of the ...
1
vote
1
answer
111
views
Why is the p5.js console warning me that some of my variables are NaN?
I'm pretty new to coding, and I've been learning p5.js for a couple of weeks. I'm trying to write some code that will draw arcs of circles between evenly-spaced points on the top and right-hand edges ...
0
votes
1
answer
123
views
How to detect a click on a sprite in p5play?
I'm using q5.js with p5play. I cannot find an easy way to detect a mouse click on a specific sprite. Whats the 'standard' way to do it in p5play?
0
votes
1
answer
56
views
p5.js ping-pong buffering causes texture glitch
I'm trying to implement a smudge effect on a texture using shaders and p5.js. I can see that the texture is being loaded into the shader and I can see the smudging, but my texture is flickering on ...
1
vote
0
answers
103
views
Creating functional flippers for a pinball game with p5.js and Matter.js
I am creating a pinball game for a school project. I am using p5.js for graphics and Matter.js for the physics. Everything else in my code is working except for the flippers, which keep firing ...
0
votes
0
answers
58
views
Instability of the components in the Matter JS engine
I am simulating a snooker game via JavaScript using the P5 and Matter JS, I'm almost done but I'm having trouble with some of the ball behaviors.
I added all the balls to the engine world in Matter JS ...
0
votes
0
answers
38
views
Error not found p5.js in Vercel but Vite works fine
Not showing p5,js sketches as Vercel gives an not defined error, in Vite works fine.
Also would like to go to myproject/docs and show the jsdoc documentation.
Load my project, and sketches are not ...
1
vote
0
answers
27
views
using a preshader before the p5.js phongshader
I'd like to be able to modify the vertex positions in a vertex shader BEFORE using phongmaterial.
I can think of two solutions:
apply a shader that modifies the coordinates before the phongShader ...
1
vote
1
answer
112
views
Trying to Create a P5.js Screensaver
I'm new to P5.js and JavaScript programming in general, but I've taken a few lessons and am trying to make a few interesting images with what I know. However, I reached a few roadblocks while trying ...
0
votes
0
answers
68
views
Why is my game's lag get more worse when I play it further?
This is a prototype game about a goose who has to keep the temperature right or else the world ends. I'm trying to add in more mechanics in but I really can't move on because the lag gets worse the ...
1
vote
2
answers
165
views
Rotating 3D object using JavaScript
I am working with WebGL 3D objects within p5.js (JavaScript). I have four somewhat complicated "separate" 3D objects which, when working as planned, will be manipulated with a mouseOver ...
1
vote
0
answers
31
views
in p5.js, how to display information of a datapoint when the mouse is hovered over it
Adding function for hover and changing draw function
I want to display the information of the datapoint when the mouse is hovered over the point. I tried adding a function and updated my draw function....
1
vote
1
answer
136
views
How to Change the Default Background of bodySegmentation-mask-body-parts in p5.js?
I'm trying to change the background behind the detected body segment, but I can't get it to work. Even though I'm modifying the background(...) function, it keeps defaulting to white. Can anyone ...
3
votes
0
answers
53
views
Fractal Nested Transformation off by a few points P5JS
Note: I am not 100% sure if this question belongs here, as I dont know if the error is in the programming or in the math, please excuse me and direct me to where to post it
Hi, I am trying to make an ...
2
votes
2
answers
81
views
p5 sketch freezing every 2ish seconds
My p5.js sketch is freezing for a couple of frames every 2-3 seconds. I know p5 is not performant, but I feel like my sketch is optimized enough to not warrant this.
I think it may have to do with how ...
3
votes
1
answer
85
views
p5js Image width always returning 1
I have a very basic p5js script where I need to resize an image taken from the user via an input. I need to resize it by a percentage, so I need to know the original dimentions. For some reason, both ...
1
vote
1
answer
88
views
Can you change the line ending on p5js
Im working on a project were I need to draw some thick lines. I noticed that by default p5js lines are rounded at the ends. Is there a way to change this behavior?
strokeWeight(50);
line(150,150,300,...
1
vote
0
answers
78
views
Why can't I apply this specific invert clip to a shape?
I’m trying to apply an invert clip to a shape, but, for this specific clip shape, the clip is not being applied to the shape.
It works if the clip is not inverted, and it works with other clips, such ...
0
votes
1
answer
93
views
How not to re-render the canvas once state changes?
I have couple of states where I change on different parts of the project:
which are:
const [sketchDimensions, setSketchDimensions] = useState(SHOE_DIMENSIONS);
const [selectedSegment, ...
0
votes
1
answer
88
views
Dropdown Menu For Images P5js
I am trying to make a drop down menu in p5js that displays images. I keep running into an error with loading images. When I attempted to troubleshoot and loaded an image in another sketch I did not ...
2
votes
1
answer
81
views
Why does p5.js render colors differently when using point() in a loop vs rect()?
I'm working with p5.js to explore color rendering by creating a dynamic color gradient using the point() function. However, I've noticed that when I use point() to draw colors, they appear lighter or ...
0
votes
0
answers
44
views
Toggling audio in React without re-rendering component
I have built a game using React (and Matter JS and p5.js). It mainly has 2 variables, score (increments everytime goal is hit) and timer (decrements every second).
I want music to play in the ...
2
votes
1
answer
96
views
Creating a flat shadow effect from a circle
I've tried a bit of trig and playing with polar to cartesian coordinates but ultimately getting a bit lost on how to achieve an effect in JS. At the moment I've been using p5.js but open to other ...
2
votes
1
answer
452
views
How does p5.js instance mode work where the argument to instantiate the object is a function?
I’m having issues understanding how the P5.js instance mode works. The syntax of creating the object seems so different from anything else I’ve seen.
We’re instantiating a new object with the new p5(...
1
vote
0
answers
43
views
p5 perlin noise field can't get streaking
I know that if you have an opaque background, the previous frame appears. My goal is that the previous dots from previous frames will appear to give a streaking effect. However, setting the background ...
0
votes
1
answer
76
views
I can't make collisions work in p5js with circles
I have followed the instructions of a "TheCodingTrain" tutorial, it describes how to calculate the distance between two circles to emulate collisions. I have a lot more, but this is the code ...
0
votes
1
answer
83
views
I am having trouble figuring out how to round a number to the nearest ones place in p5.js
I have a game I'm making in p5.js, and I am having trouble rounding my health variable to the nearest one's place.
I tried using p5.js's round() function, and it doesn't fit my problem.
I don't think ...
1
vote
0
answers
85
views
p5.js on OpenProcessing, sketch using audio works on desktop but not on mobile
Good afternoon all;
Forgive me as I am very much a 'bodger' when it comes to coding so would appreciate your patience with my noviceness! I have made a rough sketch oppr.org/s/twgjO43M on ...
0
votes
1
answer
54
views
How to correctly convert images and attach to canvas in p5js?
Currently I'm working on a big project where I'm drawing the shoe model in canvas and using some functions to divide them into segments. Those segments are clickable in order to change the images ...
0
votes
0
answers
62
views
Can't access element's properties using DOM in p5.js
I am trying to expand on The Coding Train's Monty Hall Problem demonstration using p5.js, and I am stuck in trying to implement an automatic mode.
Everything works fine, except that the background of ...
0
votes
1
answer
113
views
Trouble with reading a noise texture in GLSL
I'm writing a Perlin noise terrain generator with p5js, following this tutorial. The app ran poorly so I decided to rewrite it with shaders, something i've never used before. I started by generating a ...
0
votes
2
answers
39
views
How to write text on the right side in an inverted geometric reference frame with p5
In p5, axis y points downwards. This code make it point upwads (and make the 0,0 the center)
type gridRange={
xrange:{
min: number,
max: number,
},
yrange:{
min: ...