New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webgl-sketch

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webgl-sketch - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

.eslintrc

13

package.json
{
"name": "webgl-sketch",
"version": "0.3.0",
"version": "0.4.0",
"description": "A WebGL canvas—shader wrapper library",

@@ -13,3 +13,12 @@ "keywords": [

"main": "src/index.js",
"repository": "github:joshforisha/webgl-sketch"
"repository": "github:joshforisha/webgl-sketch",
"scripts": {
"test": "echo \"TODO: tests\""
},
"devDependencies": {
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.0.5"
}
}

32

src/index.js

@@ -13,3 +13,3 @@ const positions = new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]);

export function create(options = {}) {
const canvas = options.canvas || document.createElement('canvas');
const canvas = options.canvas || document.createElement("canvas");
const [width, height] = options.size || [200, 200];

@@ -19,12 +19,12 @@ const isDynamic = Boolean(options.dynamic);

canvas.setAttribute('height', height);
canvas.setAttribute('width', width);
canvas.setAttribute("height", height);
canvas.setAttribute("width", width);
const gl = canvas.getContext('webgl', {
const gl = canvas.getContext("webgl", {
antialias: false,
preserveDrawingBuffer: true
preserveDrawingBuffer: true,
});
if (!gl) {
throw 'A WebGL rendering context could not be initialized.';
throw "A WebGL rendering context could not be initialized.";
}

@@ -59,8 +59,8 @@

attachArrayBuffer(gl, program, 'a_texcoord', texcoords);
attachArrayBuffer(gl, program, 'a_position', positions);
attachArrayBuffer(gl, program, "a_texcoord", texcoords);
attachArrayBuffer(gl, program, "a_position", positions);
const setUniform = makeSetUniform(gl, program);
setUniform('resolution', [width, height]);
Object.keys(uniforms).forEach(key => {
setUniform("resolution", [width, height]);
Object.keys(uniforms).forEach((key) => {
setUniform(key, uniforms[key]);

@@ -73,3 +73,3 @@ });

? () => {
setUniform('time', (Date.now() - start) * 0.001);
setUniform("time", (Date.now() - start) * 0.001);
gl.drawArrays(gl.TRIANGLES, 0, 6);

@@ -82,3 +82,3 @@ window.requestAnimationFrame(render);

const rendered = new Promise(resolve => {
const rendered = new Promise((resolve) => {
window.requestAnimationFrame(render);

@@ -107,6 +107,6 @@ resolve();

const isArray = Array.isArray(value);
const method = isArray ? `${value.length}f` : '1f';
const method = isArray ? `${value.length}f` : "1f";
const name = `u_${basicName}`;
if (!uniforms.hasOwnProperty(name)) {
if (!(name in uniforms)) {
uniforms[name] = {};

@@ -122,4 +122,4 @@ }

change ||
typeof location === 'undefined' ||
typeof value === 'undefined'
typeof location === "undefined" ||
typeof value === "undefined"
) {

@@ -126,0 +126,0 @@ gl[uniformMethod].apply(gl, [location].concat(value));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc