MasoudBimar / canvas-demo

Simple demo of some <canvas> stuff

Home Page:https://canvas-demo.surge.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

canvas-demo

This repo exists for the benefit of my students, but whoever you are — welcome!

This is just a simple demo of how to paint stuff to a <canvas> element. It's very basic — for example it doesn't handle screen resizes at all well — but it illustrates the basic concepts:

var canvas = document.querySelector( 'canvas' );
var ctx = canvas.getContext( '2d' );

Here, canvas is the HTML <canvas> element that lives in index.html. ctx (pronounced 'context') is the drawing context — the thing we actually issue drawing commands to. (The alternative to 2d is webgl, which is what 3D libraries like A-Frame use.)

Read the source code in app.js to see what else is going on. When you're ready, there's a canvas tutorial on MDN that will take you much deeper.

About

Simple demo of some <canvas> stuff

https://canvas-demo.surge.sh/


Languages

Language:JavaScript 56.6%Language:HTML 29.0%Language:CSS 14.3%