What is Declarativas?


​Declarativas is a zero-dependency javascript library for declarative HTML 5 canvas context2d drawing. If you are familiar with how React renders to the DOM, declarativas aims to be that for HTML canvas applications.

Project Goals

Provide all context2d properties and draw operations from the canvas API

The context2d API has a thorough set of properties and draw functions to make it easy to just draw something on a web page. Wrapping these properties and operations in components gives users familiar with declarative web applications, like Hyperapp, React, and Vue.

Components should be easy to build

With a basic set of property and draw operation components, declarativas provides a set of building blocks that can be constructed together to build fantastic looking and functioning components. Components are just functions that return other components, just like in your favourite declarative front-end framework.

Make a higher-level API to avoid common pitfalls

One thing that can be hard to track down when using the canvas is the canvas state. It's easy to apply a transform, but forget to reset it for your next render, providing hours or days of canvas debugging. Using some higher level, built-in components, you can easily ensure that the state of the canvas does not bleed into your next render (unless you want it to!).

What declarativas is not

While declarativas is functional and declarative, it is not reactive. All this means is that batteries are not included for state management. While this can seem like an important feature, what this does is make it incredibly easy to integrate into your favourite front-end framework, which probably already includes state management. If you want state management without a separate framework, you could check out ferp, a state management library that works similar to Hyperapp and Elm's state management.
Last modified 1yr ago