Kenzo Graphics Library (KGL) is a lightweight, math-based 2D and 3D engine for web-based applications and games. Designed for speed, simplicity, and small-scale use, KGL enables fast prototyping and educational graphics applications in HTML environments without external dependencies.
<canvas>
No current featured projects...
If you made something awesome with KGL.js, share it here and get it featured on our site!
<canvas id="myCanvas" width="640" height="480"></canvas>
<script src="kgl.js"></script>
<script>
const canvas = document.getElementById('myCanvas');
const kgl = new Kgl(canvas);
function animate() {
kgl.clear();
kgl.updateRotation();
kgl.drawSolid(vertices, faces);
requestAnimationFrame(animate);
}
animate();
</script>
<!DOCTYPE html>
<hta:application>
<html>
<body>
<canvas id="c" width="640" height="480"></canvas>
<script src="kgl.js"></script>
<script>
const canvas = document.getElementById('c');
const kgl = new Kgl(canvas);
const ui = new KglUI(kgl);
const htmlBox = new KglHTSTB(canvas);
htmlBox.createBox(10, 10, 200, 100, "<b>Hello from HTA</b>");
</script>
</body>
</html>
const scenes = new KGLscenes();
scenes.add('main', () => {
voxel.drawVisibleChunks({ x: 0, y: 0, z: 0 });
});
function animate() {
kgl.clear();
scenes.render('main');
requestAnimationFrame(animate);
}
animate();
const player = new KGLentity(0, 0, 0, '#3cf');
function gameLoop() {
player.z += 0.1;
player.render(kgl);
requestAnimationFrame(gameLoop);
}
gameLoop();
render(name)
.`KGLhttp` provides a simple interface for making HTTP requests in KGL-based projects. It allows you to perform basic GET and POST requests using JavaScript's native `fetch()` with added error handling.
KGLnoise
allows generation of noise-based values for procedural terrain, visual effects, and animation.
perlin(x, y)
β Generates smooth Perlin noise.normal(x, y)
β Standard random-based noise.kenzo(x, y)
β Hybrid custom noise (mix of Perlin + random for sharper terrain edges).import { KGLnoise } from './kgl.js';
const noise = new KGLnoise();
let val = noise.perlin(12.3, 45.6); // Smooth terrain
let grain = noise.normal(32, 11); // Static noise
let hybrid = noise.kenzo(8.7, 1.2); // Mixed style
const noise = new KGLnoise();
for (let x = 0; x < 100; x++) {
for (let y = 0; y < 100; y++) {
let height = noise.kenzo(x / 20, y / 20) * 50;
kgl2d.drawRect(x * 5, y * 5, 5, 5, true);
}
}
KGLconfig.Disable3D
or Disable2D
when appropriate.KGL error : 500 (Face culling is not for 2D)
KGLconfig.UseFaceCulling = false
before initializing a Kgl2D
instance.KGL warning: Canvas tainted...
KGLconfig.Disable2D = true
, Kgl2D
will not initialize.KGLconfig.IsInDev = true
to enable dev-mode behavior.KGLconfig.info()
to print current configuration.Set flags before creating components:
KGLconfig.set({
AppName: "My Mini Game",
UseFaceCulling: true,
Disable2D: false,
DisableHTSTB: false
});
Explore the KglUI
, Kgl2D
, and KglHTSTB
classes for ready-made UI and layout tools.
KGL is ideal for indie experiments, educational demos, and rapid prototyping. While it's not intended for complex or physics-heavy projects, it remains highly extensible for creative and compact visual interfaces.
Happy coding!
Kenzo Graphics Library v2 is licensed under the GPL 3.0 License.
------------Simple--Kenzo-Graphic-Library-Preview-------------------