I2Djs-v3
  • Introduction to I2Djs
  • Getting Started
    • Installation
    • Quick Start
    • Resources
  • Guide
    • Canvas: Create-animate
    • SVG: Create-animate
    • WebGL: Create-animate
    • Data Join-Action
    • Animation-Chaining
    • Canvas: Textures & Sprite animation
    • Canvas: Heatmap
    • WebGL: Heatmap
    • WebGL: Custom Shaders
    • Canvas: GeoWorld Map with D3 modules
    • Canvas: Clipping, Masking, Pattern
    • SVG: Clipping, Masking, Pattern
    • I2Djs + Physics Engine - MatterJs
  • API Reference
    • Layers
      • Canvas Layer
      • SVG Layer
      • WebGL Layer
    • Elements API
    • Canvas additional features
    • WebGL additional features
      • Custom Shader
      • Geometry
      • Render Target
      • Texture Object
    • Join Action
    • Animation
    • Chaining
    • Path
    • Events
    • Behaviour
      • Zoom and Pan
      • Drag
  • Examples
    • Canvas
    • SVG
    • WebGL
Powered by GitBook
On this page
  • Shapes Supported:
  • Custom Elements:
  • Custom Shaders:
  • Events:

Was this helpful?

  1. API Reference

WebGL additional features

I2Djs webGL layer is for high scale performance rendering. I2Djs provides an intuitive API to render elements on large scale. However, WebGL Layer API has a minor deviation in terms of element creation, for performance reason.

To render any geometrical element, we need to load the respective shader. So for that reason, we create a shader group of the respective 'shaderType' and then create elements under it. For example, to create rectangles, we need to create 'rect' shader group and then add rect elements.

Code block to create rects.

let rectGroup = webGlLayerInstance.createEl({
					el: 'group',
					attr: {
						shaderType: 'rect'
					}
				}).createEl({
					el: 'rect':
					attr: {
						x: 100,
						y: 100,
						width: 250,
						height: 250
					},
					style: {
						fill: 'hsl(35%, 100%, 0%)';
					}
				});

Shapes Supported:

I2Djs WebGL has a pseudo-DOM implementation for most of the geometrical primitives. In addition, it provides a way to define the custom shaders and the way to feed the data to the attributes, uniforms, textures.

Below is the list of built-in elements.

Element

ShaderType

attributes

Style

rect

Rect

x, y, width, height

fill

point

point

x, y, size

fill

line

line

x1, y1, x2, y2

stroke

circle

circle

cx, cy, r

fill

polyline

polyline

d

stroke

polygon

polygon

d

fill

image

image

x, y, width, height

Custom Elements:

Sometimes there may be a need to create custom elements/effects, which are not included in the built-in options. To create custom elements, I2Djs provides an easy API to create custom shaders with the inbuild geometrical API.

Custom Shaders:

Events:

Work in progress

PreviousCanvas additional featuresNextCustom Shader

Last updated 4 years ago

Was this helpful?