webgl-2d | Canvas2D API in WebGL | Canvas library

 by   play-co JavaScript Version: Current License: MIT

kandi X-RAY | webgl-2d Summary

kandi X-RAY | webgl-2d Summary

webgl-2d is a JavaScript library typically used in User Interface, Canvas, WebGL applications. webgl-2d has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

Canvas2D API in WebGL
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              webgl-2d has a low active ecosystem.
              It has 505 star(s) with 121 fork(s). There are 52 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 15 open issues and 9 have been closed. On average issues are closed in 152 days. There are 4 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of webgl-2d is current.

            kandi-Quality Quality

              webgl-2d has 0 bugs and 0 code smells.

            kandi-Security Security

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

            kandi-License License

              webgl-2d is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              webgl-2d 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.

            Top functions reviewed by kandi - BETA

            kandi has reviewed webgl-2d and discovered the below as its top functions. This is intended to give you an instant insight into webgl-2d implemented functionality, and help decide if they suit your requirements.
            • Parse HTML .
            • Parses a string
            • tag handler
            • Style selector .
            • Advances the first token in the token input .
            • Check option .
            • Parse statements .
            • Parse JSON values .
            • Parse statement .
            • Processes a CSS value .
            Get all kandi verified functions for this library.

            webgl-2d Key Features

            No Key Features are available at this moment for webgl-2d.

            webgl-2d Examples and Code Snippets

            No Code Snippets are available at this moment for webgl-2d.

            Community Discussions

            QUESTION

            How can I make my WebGL Coordinate System "Top Left" Oriented?
            Asked 2021-Jun-07 at 08:43

            Because of computation efficiency, I use a fragment shader to implement a simple 2D metaballs algorithm. The data of the circles to render is top-left oriented.

            I have everything working, except that the origin of WebGL's coordinate system (bottom-left) is giving me a hard time: Obviously, the rendered output is mirrored along the horizontal axis.

            Following https://webglfundamentals.org/webgl/lessons/webgl-2d-rotation.html (and others), I tried to rotate things using a vertex shader. Without any success unfortunately.

            What is the most simple way of achieving the reorientation of WebGL's coordinate system?

            I'd appreciate any hints and pointers, thanks! :)

            Please find a working (not working ;) ) example here: https://codesandbox.io/s/gracious-fermat-znbsw?file=/src/index.js

            ...

            ANSWER

            Answered 2021-Jun-07 at 08:43

            Since you are using gl_FragCoord in your pixels shader, you can't do it from the vertex shader becasuse gl_FragCoord is the canvas coordinates but upside down. You could easily invert it in javascript in your pass trough to WebGL

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

            QUESTION

            Why is replacing these matrix transformations with a single bufferData call so much slower?
            Asked 2021-Apr-27 at 14:36

            I'm trying to optimize my shader that draws sprites and I originally had something like this:

            ...

            ANSWER

            Answered 2021-Apr-27 at 14:36

            For most graphics API commands what happens is that the command is encoded in a command-buffer, at some point (asynchronously) those buffers are synchronized to the GPU by the graphics driver. For a command buffer to be predictable all data needs to be copied to be put into the buffer.

            Now one problem with your code is that you're setting the data and immediately ask the GPU to draw from it, requiring a hard sync of the complete buffer. The driver expects uniforms to need syncing but not necessarily array buffers, the usage hints (DYNAMIC,STREAM and STATIC draw) don't really do much about that (actually in most cases STATIC_DRAW is faster even for dynamic data).

            When these hard syncs happen you're almost always stalling the pipeline, meaning the GPU needs to wait for all the data to be transferred before it can continue doing whatever it was doing. You can avoid this by utilizing double or even triple buffering (write data for the next frame but render current one etc.).

            However with all this being said, trying to optimize the draw of 6 quads is very problematic as (in this context) we're talking about immeasurable differences here, changing one thing over the other might change the frame-time but it doesn't say anything about scalability as you're really just measuring the (often static) overhead rather than the actual performance.

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

            QUESTION

            Shader for solid color for each triangle of plane geometry
            Asked 2021-Jan-28 at 16:20

            I have been learning webgl from webglfundamentals where I came across a simple shader example where you can paint triangles with solid color. Here is link to tutorial and original demo.

            I tried to create same effect in three js using plane geometry but I can't manage achieve solid color shader. When I use almost same setup in Three js, I get more like gradient effect. What am I doing wrong here? (I am noticing that my shader isn't consistent either as it renders differently on refresh) Also, is there place to learn shaders specifically for three js?

            ...

            ANSWER

            Answered 2021-Jan-28 at 16:20

            The PlaneBufferGeometry in three.js is using indexed vertices to share vertices so there are only 4 vertices and then 6 indices to use those 4 vertices to make 2 triangles. That means you can't give each triangle different solid colors because they share 2 vertices and a vertex can only have 1 color.

            Further, the code is choosing random colors for each vertex so even if you you used 6 vertices so that the 2 triangles didn't share any you still wouldn't get the result you linked to, instead you'd get this result which is further down the page on the same tutorial.

            Finally the code is only generating 3 floats per color so you need to set the number of components for the color attribute to 3 instead of 4

            If you want to repeat the webgl sample you'll need to provide your own 6 vertices.

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

            QUESTION

            Why won't my transformation matrix translate the points?
            Asked 2020-Jul-18 at 15:18

            I have been trying to use my own matrices in WebGL (2d at the moment). My main reference is webglfundamentals.com. I multiply a 360-degree rotation with a (1, -1) scale, (-142, 6) translation, and a projection matrix. My rectangle shows up fine, but without a translation. Here is my code:

            ...

            ANSWER

            Answered 2020-Jun-22 at 18:57

            The reason is in your shader math, z = 0.

            This line in your shader

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

            QUESTION

            Set value to jquery widget slider
            Asked 2020-Jun-06 at 19:47

            EDIT: Simpler explenation of the problem first. More detailed explanation below.

            I use some jquery widgets code to create a UI slider. The code is here:

            https://webgl2fundamentals.org/webgl/resources/jquery-gman-circle.js

            This can be used, calling the component directly in the JS script like this:

            ...

            ANSWER

            Answered 2020-Jun-06 at 19:47

            I had a closer look at your code and reduced it to the absolute minimum. It turns out you can supply the starting value of the angle simply by putting it into the empty options argument of the initiatior method: $("#example").gmanUnitCircle({value: -Math.PI/3});. In my example I chose the value of -60° in radians.

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

            QUESTION

            Set value to slider directly
            Asked 2020-May-28 at 02:53

            Javascript is a new languaje for me so this is a simple task that I cannot achieve. I can set the slider and update the position of my element when I change the slider with:

            ...

            ANSWER

            Answered 2020-May-28 at 02:53

            There's a couple of things that needed to be done in my opinion to achieve this based on the example you provided. First, the main() function on lines 98 and 99 is setting up the sliders like so:

            webglLessonsUI.setupSlider("#x", {slide: updatePosition(0), max: gl.canvas.width }); webglLessonsUI.setupSlider("#y", {slide: updatePosition(1), max: gl.canvas.height});

            If we check the library you provided (around line 99) we can see that the function setupSlider returns an object with both the html reference and a function to update its value:

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

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

            Vulnerabilities

            No vulnerabilities reported

            Install webgl-2d

            You can download it from GitHub.

            Support

            WebGL-2D is a work in progress and currently supports a very small subset of the Canvas2D API. *fill and stroke only work on straight line paths supported above, arc, and curves are not yet supported. All other properties or functions are currently stubbed. Properties are set to their defaults and functions are empty.
            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/play-co/webgl-2d.git

          • CLI

            gh repo clone play-co/webgl-2d

          • sshUrl

            git@github.com:play-co/webgl-2d.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

            Explore Related Topics

            Consider Popular Canvas Libraries

            fabric.js

            by fabricjs

            node-canvas

            by Automattic

            signature_pad

            by szimek

            dom-to-image

            by tsayen

            F2

            by antvis

            Try Top Libraries by play-co

            devkit

            by play-coJavaScript

            js.io

            by play-coJavaScript

            hookbox

            by play-coJavaScript

            orbited2

            by play-coJavaScript

            ff

            by play-coJavaScript