Get started with mogl CDN

MIT licensed

Mogl is a library for manipulating and rendering 2D vector graphics.

Tags:
  • mobile
  • webgl

Stable version

Copied!

How to start using mogl CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with mogl CDN - cdnhub.io</title>
  <script src="https://cdn.cdnhub.io/mogl/0.3.0/mogl.min.js"></script>
</head>
<body>
  <canvas id="canvas" width="200" height="200"></canvas>
  <script>
    const canvas = document.getElementById('canvas');
    const ctx = canvas.getContext('2d');

    const image = new Image();
    image.src = 'https://example.com/image.jpg';

    image.onload = () => {
      Mogl.load(image).then((texture) => {
        const renderer = new Mogl.Renderer(ctx, { width: canvas.width, height: canvas.height });
        const sprite = new Mogl.Sprite(renderer, texture, { x: 0, y: 0, width: texture.width, height: texture.height });

        renderer.render(sprite);
      });
    };
  </script>
</body>
</html>
Copied!
Copied!

All versions