Sketch.js | Vector drawing app w/ animated replay
kandi X-RAY | Sketch.js Summary
kandi X-RAY | Sketch.js Summary
:pencil2: Vector drawing app w/ animated replay. Includes eraser & brush with catmull smoothing. Can be tied into other drawing tools, and synced across servers with JSON. Built on Event.js, Color.Picker.js & Color.Space.js
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Sketch.js
Sketch.js Key Features
Sketch.js Examples and Code Snippets
Community Discussions
Trending Discussions on Sketch.js
QUESTION
I am making a simple code that you will have to put in the password and I would like to know how to make a code that will randomly distribute text. I have tried to use the push and pop methods.
...ANSWER
Answered 2021-May-06 at 17:59You can use:
text()
to render each characterrandom()
to pick a random position and angle (within a range)- use other text related functions to adjust the look of the characters such as
textFont()
to set a serif font andtextSize()
Here's a basic example with comments:
QUESTION
When I was writing the code I saw that the code would not reset the canvas to (400, 400)
after being changed to (600, 600)
. It would disorientate the canvas and stretch all the shapes with it in evaporation()
. When going through all the screens and trying to go back to reset back.
ANSWER
Answered 2021-May-19 at 19:46From the documentation for createCanvas:
Creates a canvas element in the document, and sets the dimensions of it in pixels. This method should be called only once at the start of setup. Calling createCanvas more than once in a sketch will result in very unpredictable behavior.
Instead of calling createCanvas repeatedly in your drawing functions, you should use resizeCanvas once when transitioning from one screen to another.
I couldn't actually reproduce whatever issue you were describing (partly because I could not make sense of your description). However I did also notice an issue with the variable ripple
not being declared anywhere, so I fixed that, and now the sketch appears to be working correctly.
QUESTION
- I was trying to run this code but I am getting error for not declaring variables properly.
- I have formatted this code which is previously written using a class but I am getting errors in assigning global variables.
- When I am adding fill in render() function it is getting to both circles but i need to assign blue to only middle circle
ANSWER
Answered 2021-May-18 at 05:45It is because you are declaring let can
and let center
inside a function, so it's only stored locally.
Try defining let can, center;
at the beginning of your code, and then removing the let
s inside function setup()
Something like:
QUESTION
I'm quite new at this, but I'm attempting to create a fixed distance brush in P5 where the size of the brush gets bigger/wider overtime (using a timer)
This is what the code looks like right now
...ANSWER
Answered 2021-May-16 at 02:59You are currently calculating r
for each point when drawing the path. Since you redraw the entire path each frame all of the segments will grow. To prevent this you need to make r
something that you calculate when you are adding points and include it in the data structure for the path.
QUESTION
I am making a simple bank system and I've been having trouble with creating a button that changes the screen and It would change the screen as button is pressed. I have tried using code such as screen = 1;
in the problem but it doesnt seem to work
ANSWER
Answered 2021-May-11 at 20:26There are numerous issues with the posted code, and it is hard to tell which are because this code is incomplete, and which are bugs. However here are a few issues that stand out.
- You have no
setup
function - You are creating a new canvas on every call to
begining
which doesn't make much sense. - You are creating HTML elements in functions called in
draw
- Unless you disable looping you should not do this because HTML elements are persistent.
- You are calling
noLoop
as an instance method onp5.Element
in multiple places, this is not valid. - In the button function you create 200 "Next" buttons, that's probably not what you want to do.
- In the
button
function you do a bunch of drawing, but unless looping is disabled this will immediately be covered up by the call tobackground
inbankScreen
on the next execution ofdraw
- You don't remove the elements from the "beginning" screen when the submit button is clicked and you try to move to the "bankScreen"
- When next page is clicked you are already on screen = 1 so that function has no effect.
I've attempted to fix the issues with your code:
QUESTION
The project I'm working on should have the code createCapture but it doesn't work when I run the code despite having a createCapture() in the code.
When I run it, I would click to the second page and there should be a createCapture on the second page. The camera should turn on, When Clicking to the second page
The JS Code:
...ANSWER
Answered 2021-Apr-28 at 07:32It's possible that you don't have permission to access the camera in the context where you are using this code. If your code is running in an iframe on another website it may have restrictions that prevent it from even requesting access to the webcam.
Other than that your code mostly works. However, when you get to screen 1 (a.k.a. mainScreen) you are currently recreating the buttons and capture every frame, which is not what you want to do. Both buttons and capture objects are persistent, so you only need to create them once.
Additionally, while your code displays the webcam video on the screen it will not be present in the file generated when you click saved. This is because creating a capture object doesn't actually draw the captured images to your canvas. Instead you need to hide the capture object and draw it as an image to the canvas. Here is a working version of your code hosted on p5js.org. And bellow is an abridge version with just the relevant bits:
QUESTION
I am currently making a brush in p5.js
...ANSWER
Answered 2021-May-08 at 09:05In order to draw your arrow head you will need to draw the desired triangle when the mouse is released. P5.js will call various input event functions when the user performs input actions and one such function is mouseReleased()
. Here is an example of drawing arrow heads in the mouseReleased
function.
QUESTION
Hi have a simple script where I draw a circle in the middle of the canvas! What I want to do is to add the canvas at a specific point of the DOM.
Here is my code where I try to add the canvas inside the div with id canvas
instead of where the script is!:
ANSWER
Answered 2021-May-06 at 18:06I checked the p5js docs and found out how to do it. Look at setup for the changes.
QUESTION
I'm working on an interactive pH spectrum (Alkaline & Acidic Foods Chart) where I want the user to be able to add two inputs; a minimum and maximum level of pH for a plant! For example:
- Input_1: 5.9
- Input_2: 8.2
What I want to do is draw a new arc and highlight the selected area!
Here is what I have so far but I have no idea how to implement this, since I use the i
from my for loop to create this chart and i
is not decimal!
ANSWER
Answered 2021-May-05 at 19:44You can do something similar to this. I set the x and y to the values of num1 and num2 in a loop. I don't fully understand why it would be useful but maybe it can help you in the right direction.
UPDATE:
QUESTION
I'm a beginner at using p5.js but I'm currently currently attempting to create a brush sketch like this ellipse brush
though using computer vision & posenet nose tracking (essentially a nose brush)
The problem is, while it doesn't state any errors, it doesn't work.
This is my code for the ellipse brush without posenet & camera vision
...ANSWER
Answered 2021-May-01 at 02:26You're shifting properly, but you forgot to clear the pg
graphic, which is kind of like forgetting to put background(0)
in your original sketch. So instead of drawing all the ellipses on a blank background, you're drawing them on top of the previous frame.
Adding pg.clear()
anywhere in draw()
after you display pg
on the canvas (image(pg, ...)
) and before you draw the ellipses (for (...) {... ellipse(nosePosition[i].x...)}
) should do the trick. Here's where I put it:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Sketch.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page