p5js | Simplex Noise & WebGL with p5js from Processing.Org | Graphics library

 by   pjkarlik JavaScript Version: Current License: No License

kandi X-RAY | p5js Summary

kandi X-RAY | p5js Summary

p5js is a JavaScript library typically used in User Interface, Graphics, WebGL applications. p5js has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

My Experiments with p5js using simplex noise on 3d grids and matrix systems. You can change the render file called in index.js, each variation explores different features in rendering and shader functions. Using dat-gui to control display and render options. Current Mapping --> index.js --> (render file) renders\Render.js (or just about any other file in src). Render - Original Render, initial framework with basic interaction.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              p5js has a low active ecosystem.
              It has 12 star(s) with 3 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              p5js has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of p5js is current.

            kandi-Quality Quality

              p5js has 0 bugs and 0 code smells.

            kandi-Security Security

              p5js has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              p5js code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              p5js does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              p5js releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.
              It has 42 lines of code, 0 functions and 11 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of p5js
            Get all kandi verified functions for this library.

            p5js Key Features

            No Key Features are available at this moment for p5js.

            p5js Examples and Code Snippets

            No Code Snippets are available at this moment for p5js.

            Community Discussions

            QUESTION

            activate one thing deactivate the other if i say a certain word
            Asked 2022-Apr-08 at 12:04

            I have a code that activates an image and leaves it activated but i want to change to other images if the parameters are met. i want to activate one thing and deactivate the other if i say a certain word

            My code: https://editor.p5js.org/perikleousd910/sketches/OI1glzfWS

            ...

            ANSWER

            Answered 2022-Apr-08 at 12:04

            If I understand you correctly, you might want something like this; the global variable shownImageSet is "held" to the last value if there is no pose and label.

            There is no need for flag/flag2 variables.

            Source https://stackoverflow.com/questions/71796406

            QUESTION

            P5js sketch slow with WEBGL
            Asked 2022-Mar-24 at 00:02

            I created a sketch which draws 100s of thousands of lines. As expected, it is quite slow. So, I tried the same sketch with WEBGL mode. But this turned out to be slower than the default mode.

            My understanding was that WEBGL leverages GPU for fast rendering. Is it not true?

            Thank you.

            createCanvas(windowWidth, windowHeight, WEBGL)

            Side note: I coded this sketch first in Processing (java), where the WEBGL mode was 100 times faster than the default mode. So, I expected the same with P5js.

            ...

            ANSWER

            Answered 2022-Mar-24 at 00:02

            Drawing numerous stroked shapes in p5.js with WEBGL is notoriously slow. See: Sketch runs slow in P5.js WEBGL on the processing.org Discourse forum. If you specifically want to draw lines and/or curves and you don't need 3d perspective then a 2d canvas will actually perform better (and in most browsers it will still utilize the GPU). If you are actually utilizing 3d perspective and other WEBGL rendering capabilities then the key thing is to reduce the number of drawing instructions, and if possible avoid relying on p5.js to draw strokes. In order to give you more specific advice on how to do that you are going to have to post a minimal reproducible example of what you are trying to do.

            Source https://stackoverflow.com/questions/71595063

            QUESTION

            How to move ellipse filled with an image to mask similar background?
            Asked 2022-Mar-21 at 03:56

            I am a super early user of coding from Italy. I came up with an idea to promote a company logo on their website and I almost reached the goal so I am sharing this problem.

            The idea is to obtain a sort of clipping mask effect when the mouse/cursor move on the image I've made so far a code that does the work with a still ellipse.

            When I set the position parameters of the ellipse as mouseX and mouseY the effect does not work if not just a bit of a glitch at the start. How can I make it work as intended?

            Here you can find the link of what I have now: https://editor.p5js.org/francesco.ficini.designer/full/FLBuhggW-

            Here the code:

            ...

            ANSWER

            Answered 2022-Mar-21 at 03:56

            The thing about the p5.Image.mask function is that it modifies the image that is being masked. Which means that any pixels that are cleared by the mask are gone for good. So if you want to dynamically change the mask you will need to make a copy of the original and re-apply the modified mask any time it changes.

            Additionally you will want to avoid creating images and graphics objects in your draw() function because this can result in excessive memory allocation. Instead create a single set of graphics/images and re-use them.

            Source https://stackoverflow.com/questions/71548648

            QUESTION

            How do I add an uploaded image to specific scenes?
            Asked 2022-Mar-19 at 18:40

            What I am trying to create is a point and click adventure game with decisions that effect your outcome. So far, I have only added text so I wanted to upload images and use them in my scenes. One of my attempts to get this to work is as below as well as an example of one of the scenes. I also tried creating properties within the scene and then tried code something along the lines of image(scenes[pointer].sceneGraphic, scenes[pointer].graphicXPosition, scenes[pointer].graphicYPosition), which resulted in a possible scope error in the console.

            The following code can be seen in full at this p5js editor link.

            ...

            ANSWER

            Answered 2022-Mar-13 at 22:29

            The line containing if (scenes[pointer] == 4) { should be if (pointer == 4) { if you wanted the image to be drawn on the canvas. Changing that on your p5js editor link drew the cat image after pressing Space until it showed Scene 4.

            As for setting images in each specific scene, you just need to reference the image when setting up each scene such as

            Source https://stackoverflow.com/questions/71460647

            QUESTION

            Beginners' question on p5js print() function
            Asked 2022-Mar-10 at 20:37

            I have seen some closed posts on GitHub, and the occasional unsolved similar question on random returns, but I can get a good explanation as to why on a simple print() command of a defined object the object is being printed on the console seemingly in a loop:

            I just started using p5js, and don't know javascript. So it may be where the commands are placed (function setup() or function draw()), which I am still unsure why they are defaulted on the editor start page, or else I need to specify that I want the result printed just once (?).

            ...

            ANSWER

            Answered 2022-Mar-10 at 20:37

            This happens because draw() runs on a loop. Behind the scenes, the p5js library is using requestAnimationFrame to call draw().

            You could move the print statement to be within the setup() function, which only runs once at the start of the script.

            Source https://stackoverflow.com/questions/71418243

            QUESTION

            What could be the reason that my p5js object instance isn't rendering correctly?
            Asked 2022-Mar-02 at 01:56

            I'm using p5js to turn some barnsley fern code into an object using the coding train's code.

            I'm trying to animate it by changing one of the coefficients but I need the fern to at least render properly as an object first.

            My issue is that the fern doesn't render correctly after I've ported the properties and methods into a barnsley fern object. The only thing that renders sometimes is the stem but none of the leaves do.

            I've tried changing the order in the draw function, using a function factory approach and object literals but I keep getting the same result 😭

            Here is the p5sketch so you can see

            ...

            ANSWER

            Answered 2022-Mar-02 at 01:56

            You missed out updating r in the nextPoint() function

            Source https://stackoverflow.com/questions/71315977

            QUESTION

            p5.js how to correctly compute the 3D rotation of a point in respect of the origin
            Asked 2022-Feb-26 at 22:25

            I'm really struggling here and I can't get it right, not even knowing why. I'm using p5.js in WEBGL mode, I want to compute the position of on point rotated on the 3 axes around the origin in order to follow the translation and the rotation given to object through p5.js, translation and rotatation on X axis, Y axis and Z axis.

            The fact is that drawing a sphere in 3d space, withing p5.js, is obtained by translating and rotating, since the sphere is created at the center in the origin, and there is no internal model giving the 3d-coordinates.

            After hours of wandering through some math too high for my knowledge, I understood that the rotation over 3-axis is not as simple as I thought, and I ended up using Quaternion.js. But I'm still not able to match the visual position of the sphere in the 3d world with the coordinates I have computed out of the original point on the 2d-plane (150, 0, [0]).

            For example, here the sphere is rotated on 3 axis. At the beginning the coordinates are good (if I ignore the fact that Z is negated) but at certain point it gets completely out of sync. The computed position of the sphere seems to be completely unrelated:

            It's really hours that I'm trying to solve this issue, with no result, what did I miss?

            Here it follows my code:

            ...

            ANSWER

            Answered 2022-Feb-26 at 22:25

            I've finally sorted out. I can't really understand why works this way but I didn't need quaternion at all, and my first intuition of using matrix multiplications to apply rotation on 3-axis was correct.

            What I did miss in first instance (and made my life miserable) is that matrix multiplication is not commutative. This means that applying rotation on x, y and z-axis is not equivalent to apply same rotation angle on z, y and x.

            The working solution has been achieved with 3 simple steps:

            1. Replace quaternion with matrix multiplications using vectors (method #resize2)
            2. Rotating the drawing plane with Z-Y-X order
            3. Doing the math of rotation in X-Y-Z order

            Source https://stackoverflow.com/questions/71197127

            QUESTION

            get() function returns an empty pixels array in p5.js
            Asked 2022-Feb-23 at 20:00

            The thing that i wanna do is similiar with this video. In p5.js, I am using get() function. After use this, I will create small images (by dividing big tileset) and push them into an array. But in my code get() returns an empty pixels array. Here is a part of my code:

            ...

            ANSWER

            Answered 2022-Feb-23 at 20:00

            I believe the issue here is that you are not waiting for the image to actually be loaded. The loadImage function is asynchronous. That is, it only starts the process of loading the image, but it returns before it actually finish loading the image. So any code that comes after that will run immediately, while the loading is still in progress. You can use the callback function to run code after loading is complete. Here's a modified version of your code that should alleviate the problem:

            Source https://stackoverflow.com/questions/71235505

            QUESTION

            Why does this undo logic not work in p5.js?
            Asked 2022-Feb-23 at 15:16

            My logic is simple, create a state array and a stateIndex, when the user interacts with the drawing, save the current state as an entry in the array and increment the stateIndex.

            When the user presses "undo" (for this sketch press any key), decrement the stateIndex and draw to the page whatever value is in state for that index.

            I've implemented it in this sketch https://editor.p5js.org/mr_anonymous/sketches/s0C1M7x1w but as you can see instead of storing the last state of the drawing it seems to only store the blank state.

            Anyone know what's going wrong?

            Edit: Added source code

            ...

            ANSWER

            Answered 2022-Feb-23 at 08:52

            You're using the set() function incorrectly. While get() can be used to get a p5.Image object, there is no overload of set() that takes one (a bit idiosyncratic, I know). Instead you'll want to use the image() function:

            Source https://stackoverflow.com/questions/71231952

            QUESTION

            Create a promise here, resolve it there
            Asked 2022-Feb-15 at 16:59

            I thought I had the hang of promises in all situations, but I'm stuck here: I'd like an animation to happen on a timer. The only thing I can get from the graphics package is the frame number, so I compute an end frame based on a frame rate estimate.

            The graphics package is p5.js, which exposes frameCount, that just runs up at about 60 fps on each draw cycle. (I named it currentFrame in this question, hoping that would clarify). As far as I can tell, this is the only visibility I get into the animation frame state in p5.js

            ...

            ANSWER

            Answered 2022-Feb-14 at 18:02

            Instead of storing the promise to resolve, you need to store the resolver to call:

            Source https://stackoverflow.com/questions/71116182

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install p5js

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/pjkarlik/p5js.git

          • CLI

            gh repo clone pjkarlik/p5js

          • sshUrl

            git@github.com:pjkarlik/p5js.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link