Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
glsl-cartesian-to-barycentric
Advanced tools
glslify module to convert cartesian to barycentric coordinates
glslify module to convert cartesian to barycentric coordinates
This example creates a shader over the whole screen and calculates barycentric
coordinates for a triangle described by p0
,p1
,p2
.
The color channel is set to the barycentric coordinates for points inside the triangle.
var glsl = require('glslify')
var regl = require('regl')()
var draw = regl({
frag: glsl`
precision highp float;
#pragma glslify: c2b = require(../)
varying vec2 vpos;
void main () {
vec2 p0 = vec2(-0.5,+0.1);
vec2 p1 = vec2(+0.6,+0.5);
vec2 p2 = vec2(-0.2,-0.3);
vec3 bc = c2b(vpos, p0, p1, p2);
if (max(bc.x,max(bc.y,bc.z)) > 1.0) discard;
if (min(bc.x,min(bc.y,bc.z)) < 0.0) discard;
gl_FragColor = vec4(bc*0.5+0.5,1);
}
`,
vert: `
precision highp float;
attribute vec2 position;
varying vec2 vpos;
void main () {
vpos = position;
gl_Position = vec4(position,0,1);
}
`,
attributes: {
position: [-4,-4,-4,+4,+4,+0]
},
elements: [0,1,2]
})
frame()
window.addEventListener('resize', frame)
function frame () {
regl.poll()
regl.clear({ color: [0,0,0,1], depth: true })
draw()
}
#pragma glslify: c2b = require(glsl-cartesian-to-barycentric)
Calculate the barycentric coordinates for a cartesian coordinate p
in a
triangle defined by the cartesian coordinates a
, b
, and c
.
To go from barycentric back to cartesian coordinates:
vec2 p = a * bc.x + b * bc.y + c * bc.z;
npm install glsl-cartesian-to-barycentric
bsd
FAQs
glslify module to convert cartesian to barycentric coordinates
The npm package glsl-cartesian-to-barycentric receives a total of 1 weekly downloads. As such, glsl-cartesian-to-barycentric popularity was classified as not popular.
We found that glsl-cartesian-to-barycentric demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.