Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
image-shader
Advanced tools
Tool to simplify writing shaders for HTML Image and Canvas elements.
This class class creates a webgl context and texture from a given HTMLImageElement
or HTMLCanvasElement
as
well as a fragment shader.
The shader is wrapped with the necessery definitions and functions to render the image.
import { ShaderImage } from "shader-image";
const source = new Image();
source.src = "some/url.png";
// only render the red channel of the image.
const shader = `
void main() {
vec4 pixel = getImagePixel();
gl_FragColor = vec4( pixel.r, 0, 0, 1 );
}
`;
const image = new ShaderImage( source, shader );
document.body.appendChild( image.domElement );
new ShaderImage( source, shader )
where source
is either a HTMLImageElement
or a HTMLCanvasElement
and the
shader
is a string in form of webgl
shader. This means it has to include a void main()
method in which or
subsequently from which the gl_FragColor
is set.
Within the shader, these extra values are accessable:
vec4 getImagePixel()
: Returns a vec4
of the current pixel in the fragment.vec2 uv
: The UV Coordinates of the current pixel.domElement
Returns a HTMLCanvasElement
in the size of the source image containing the shaded image.width
Returns the width of the content.height
Returns the height of the content.dispose()
Releases all memory. Since it uses WebGL internally, simply losing the reference will not clear
all memory.FAQs
Run WebGL shaders on an image or canvas.
We found that image-shader 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.