github.com/fgaz/shine ↗
Declarative graphics for the browser
Open this visualization on its own page →
Contributors
2
Lines of Code
181
From
2016-01-28
To
2020-07-10
About fgaz/shine
Shine is a Haskell library that provides a declarative API for creating graphics in web browsers. It wraps JavaScript's canvas drawing functions and is inspired by the Gloss graphics library, allowing developers to build visual compositions using a functional, tree-based Picture datatype. Pictures can be combined using monoid operations, making it easy to compose complex drawings from simpler components.
The library supports both static and animated graphics through functions like `animate` for time-based animations and `play` for interactive graphics that respond to mouse and keyboard input. Users define their visual output by constructing Picture objects with transformations like translation and basic shapes, then render them to a canvas using provided utility functions. The project compiles Haskell code to JavaScript via GHCJS, enabling pure functional graphics programming to run directly in the browser.
Shine includes an examples package demonstrating various use cases, from simple animated shapes like oscillating circles to interactive applications that respond to user input. The library is aimed at Haskell developers who want to create web-based graphics using functional programming principles, avoiding imperative canvas APIs while maintaining access to their full expressiveness.