element-functions-set_background_canvas
v3.0.0
Published
Sets an Image or GLSLFragmentShader as the background of any Element.
Downloads
6
Maintainers
Readme
setBackgroundCanvas
Sets an Image or GLSLFragmentShader as the background of any Element.
This functions allows you to apply a Image or GLSLFragmentShader behind all element children. By using this function you will have far more control. The main reason for this was to allow opacity over an still background image without effecting nested elements. Now each nested element can have its own alpha use setAlpha project for this. Use the opacity rule for the canvas.
Make sure your parent Element has the CSS rule position: relative;.
Demostration Site
img1.onload = function () {
document.getElementById("your_block_level_element").setBackgroundCanvas(img1);
};
img1.crossOrigin = "anonymous"; /* required removes: operation is insecure */
img1.src = 'https://upload.wikimedia.org/wikipedia/commons/9/9b/The.Matrix.glmatrix.2.png';
/* create a function for Loaded event within parent element */
parentElement.glslFragmentShaderLoaded = function(event){
/* set your size */
glslFragmentShader.size = 4; // between .5 - 8
/* add to the background */
parentElement.setBackgroundCanvas(glslFragmentShader);
}
You can access the canvas element directly by using
You can access the reFresh function if you have any refreshing issues with
Triggered when a change to the canvas object.
By including this module you will get an extra reFresh call.
To reposition the image use two classes on the canvas element, both x and y classes are needed.
9 positions are possible
So for a center image use
The object ether image, video can be stretched over the element, using the following classes. aspect ratio is ignored.
Use the opacity rule, inheritance will not be effected as it's on it own branch.
Levels were added for manipulation of pixels just in case there is some chroma pixels remaining. The class of levels must be added to the Element or it will be ignored
Apply a color of chroma key to the GLSLFragmentShader or Image the class of chromaKey must be added to the canvas element to function, make sure you slect the exact colour of the chroma key.
Apply an amount of chroma variance to the GLSLFragmentShader or Image the class of chromaKey must be added to the canvas element to function