All Projects → KaliedaRik → Scrawl Canvas

KaliedaRik / Scrawl Canvas

Licence: mit
Responsive, integrated and interactive HTML5 canvas elements. Scrawl-canvas is a JavaScript library designed to make using the HTML5 canvas element a bit easier, and a bit more fun!

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Scrawl Canvas

Udoit
The Universal Design Online content Inspection Tool, or UDOIT (pronounced, “You Do It”) enables faculty to identify accessibility issues in Canvas by Instructure. It will scan a course, generate a report, and provide resources on how to address common accessibility issues.
Stars: ✭ 80 (-40.3%)
Mutual labels:  accessibility, canvas
Va11ys
Verified Accessibility Samples - Testing the accessibility of HTML & ARIA samples
Stars: ✭ 94 (-29.85%)
Mutual labels:  accessibility, html5
Binari
Interactive code editor with a live binary tree visual designed to teach new developers the fundamentals of dynamic programming.
Stars: ✭ 82 (-38.81%)
Mutual labels:  html5, canvas
Hqchart
HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据替换接口
Stars: ✭ 1,126 (+740.3%)
Mutual labels:  html5, canvas
Construcao De Paginas Web
Desenvolvimento de páginas semânticas, acessíveis e responsivas. 🚀
Stars: ✭ 113 (-15.67%)
Mutual labels:  animations, html5
Wheel Of Lunch
HTML5 randomised spinning wheel to select a place to eat by using a RESTful API to fetch local places.
Stars: ✭ 70 (-47.76%)
Mutual labels:  html5, canvas
My Animate
使用 HTML5 / Canvas / CSS3 制作各种动画效果
Stars: ✭ 93 (-30.6%)
Mutual labels:  html5, canvas
Literallycanvas
A canvas in your browser. Literally.
Stars: ✭ 1,043 (+678.36%)
Mutual labels:  html5, canvas
The Matrix Effect
The incredible effect of rain of letters in the style of the Matrix trilogy.
Stars: ✭ 109 (-18.66%)
Mutual labels:  html5, canvas
Textor
Experimental Text Editor using HTML5 canvas.
Stars: ✭ 107 (-20.15%)
Mutual labels:  html5, canvas
Tower game
💒 盖楼游戏 html5 canvas tower building game 🏢🏬🏦🏯🏰
Stars: ✭ 1,110 (+728.36%)
Mutual labels:  html5, canvas
Hilo3d
Hilo3d, a WebGL Rendering Engine.
Stars: ✭ 123 (-8.21%)
Mutual labels:  html5, canvas
Asciidoctor Html5s
Semantic HTML5 converter (backend) for Asciidoctor
Stars: ✭ 50 (-62.69%)
Mutual labels:  accessibility, html5
Icon Machine
Web application for randomly generating pixel art icons.
Stars: ✭ 73 (-45.52%)
Mutual labels:  html5, canvas
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-62.69%)
Mutual labels:  html5, canvas
Buddycss
The framework for people who love coding!
Stars: ✭ 89 (-33.58%)
Mutual labels:  accessibility, html5
Minipaint
online image editor
Stars: ✭ 1,014 (+656.72%)
Mutual labels:  html5, canvas
Curtainsjs
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.
Stars: ✭ 1,039 (+675.37%)
Mutual labels:  html5, canvas
Micro Racing
🚗 🏎️ 🎮 online 3D multiplayer neural networks based racing game
Stars: ✭ 100 (-25.37%)
Mutual labels:  html5, canvas
Freeciv Web
Freeciv-web is an Open Source strategy game implemented in HTML5 and WebGL, which can be played online against other players, or in single player mode against AI opponents.
Stars: ✭ 1,626 (+1113.43%)
Mutual labels:  html5, canvas

Scrawl-canvas Library

Version: 8.5.2 - 11 Mar 2021

Scrawl-canvas website: scrawl-v8.rikweb.org.uk.

Do you want to contribute? I've been developing this project for too long by myself, and would really welcome contributions from - even collaboration with - people who can bring a different perspective and a fresh set of eyes to the work.

Rate on Openbase

What?

Scrawl-canvas is a JavaScript library for working with the HTML5 <canvas> element. The library:

  • Automatically discovers existing <canvas> elements in a web page.
  • Can add new <canvas> elements to the web page.
  • Defines a set of factory functions for creating a wide range of graphic artefacts and effects, which can be drawn on a canvas.
  • Includes an adaptable - yet easy to use - protocol for positioning, displaying and animating artefacts and effects across the canvas.
  • Adds functionality to make <canvas> elements responsive, adapting their size according to their surrounding environment.
  • Makes the canvas both accessible, and interactive - including the ability to easily track user interactions with different parts of the canvas.

Why?

There are a number of other Javascript libraries available, each with their strengths and weaknesses. Some have been designed to make the production of charts and other data visualisations easier. Some focus on game development, others on making videos interactive. Libraries which attempt to emulate Flash/Actionscript animations have been developed, as have libraries whose aim is to combine 2D, 3D and even SVG graphics into a usable whole. Speed is a key goal for some of the best libraries, while ease-of-use is an objective for many others.

Working with the native Canvas API is hard work - particularly when the desired result is more complex than a couple of coloured boxes in a static display.

But the benefits of using canvases for graphical displays and animations are also great: canvases are part of the DOM (unlike Flash); they are natively wired for events and user interactions; they use immediate mode redering (which makes them very quick); and the canvas-related APIs are designed to be used with Javascript.

Yet these advantages are also significant barriers:

  • Working directly with the canvas-related APIs leads to writing significant amounts of JS boilerplate code.
  • <canvas> elements can be resized and styled using CSS, but changing the CSS size does not affect the element's drawing dimensions - leading to sub-optimal graphic displays.
  • Events work on the canvas, not on the artefacts within the canvas - we cannot use artefacts as links or hot-spots (click/tap events), we cannot give them the equivalent of a CSS hover state (focus/blur events), we cannot drag-and-drop them around the display (move events).
  • Tracking a user's interaction with the various parts of a canvas display is particularly difficult.
  • We cannot save and share artefacts and effects; each canvas display is tightly coupled to the code that defines the display.
  • Of most concern, canvases are entirely graphical - visual - by nature; they come with significant accessibility issues. Given the ever-stricter requirements for websites to be accessible to all users, this makes using a canvas to present important information a dangerous proposition.

Scrawl-canvas overcomes these barriers

Yes, Scrawl-canvas aims to be fast, and developer-friendly. It also aims to be broadly focussed, suitable for building infographics, games, interactive videos - whatever we can imagine for a 2D graphical presentation.

But the main purpose of Scrawl-canvas is to make the <canvas> element, and the parts that make up its displays and animations, responsive, interactive, linkable, trackable. And accessible!

Installation and use

There are three main ways to include Scrawl-canvas in your project:

Download, unpack, use

  1. Download the zipped file from GitHub
  2. Unzip the file to a folder in your project.
  3. Import the library into the script code where you will be using it.

Alternatively, a zip package of the v8.5.2 files can be downloaded from this link: scrawl.rikweb.org.uk/downloads/scrawl-canvas_8-5-2.zip - this package only includes the minified file.

<!-- Hello world -->
<!DOCTYPE html>
<html>
<head>
    <title>Scrawl-canvas Hello World</title>
</head>
<body>
    
    <canvas id="mycanvas"></canvas>

    <!-- The library is entirely modular and needs to be imported into a module script -->
    <script type="module">

        import scrawl from './relative-or-absolute/path/to/scrawl-canvas/min/scrawl.js';

        // Get a handle to the canvas element
        let canvas = scrawl.library.canvas.mycanvas;

        // Setup the scene to be displayed in the canvas
        scrawl.makePhrase({

            name: 'hello',
            text: 'Hello, World!',

            width: '100%',

            startX: 20,
            startY: 20,

            font: 'bold 40px Garamond, serif',
        });

        // Render the canvas scene once
        canvas.render()
        .catch(err => {});

    </script>

</body>
</html>

CDN - unpkg.com

This will pull the requested npm package directly into your web page:

<script type="module">
    import scrawl from 'https://unpkg.com/[email protected]';
    [...]
</script>

NPM/Yarn

This approach is still experimental: Scrawl-canvas has been designed for use in the browser, not server-side. Add the library to a React/Vue/Svelte/etc project at your own risk - your mileage may vary!

  1. Add the library to your project using NPM or Yarn
  2. Import the library into the script code where you will be using it.
// either
$> npm install scrawl-canvas

// or
$> yarn add scrawl-canvas

// then in your script file
import scrawl from 'scrawl-canvas';

// Scrawl-canvas has no dependencies
// - it can be used as-is, with no further installation steps required

Local development and testing

After downloading the library and unzipping it into a directory or folder, cd into that folder on the command line, run yarn install or npm install (for the toolchain - the library itself has no external dependencies) and start a local server. For instance if you have light-server installed:

$> cd ./path/to/Scrawl-canvas
$> yarn install
$> light-server --serve . --open

light-server is listening at http://0.0.0.0:4000
  serving static dir: .

Testing

The code base does not include any unit testing frameworks. Instead, we rely on a set of Demo tests which allow us to perform integration testing and user interface testing.

Why this approach? Because most of the Scrawl-canvas functionality revolves around various forms of animation, which requires visual inspection of the Demo tests to check that the canvas display - and thus, by inference, the underlying code - performs as expected.

Most Demos include some form of user interaction, which allows us to test specific aspects of the code base.

Documentation

The source code has been extensively commented. We generate documentation from that code using Docco. Documentation is regenerated each time the library is rebuilt.

Minification

We minify the source code using rollup and its terser plugin.

Building the library

Running the following command on the command line will recreate the minified file, and regenerate the documentation:

$> yarn build

Development team

Developed by Rik Roots: [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].