Git Product home page Git Product logo

retro-fire-css's Introduction

RetroFireCSS

Summary

Inspired from games of the 80's and 90's, RetroFireCSS applies a dynamically generated retro fire effect to the background of page elements

Demos

Heading showcase

Feature showcase

Quick Start

<!-- Import the RetroFireCSS painter -->
<script src="/src/lib.js"></script>

<!-- Apply RetroFireCSS painter -->
<h1 style="background: paint(retro-fire);">I'm on fire</h1>

Features

  • Fire is dynamically rendered each time element is redrawn
  • Adaptive to dimensions of element
  • Accepts simulation parameters;
    • --fire-ambient
    • --fire-turbulence
    • --fire-scatter
  • Accepts rendering parameters;
    • --fire-scale

API

The following (optional) CSS variables provide per element control over rendering and simulation behavior:

.retro-fire-background {
  /* Rendering pixelation [1-100] */
  --fire-scale: 4;

  /* Randomize fuel distribution [0.0-1.0] */
  --fire-scatter: 0.25;

  /* Scale randomized heat diffusion [0.0-1.0] */
  --fire-turbulence: 0.25;

  /* Ambient heat [0.0-1.0] */
  --fire-ambient: 0.125;

  /* Apply retro fire worklet */
  background: paint(retro-fire);
}

Examples

Example of RetroFireCSS result Example of RetroFireCSS result Example of RetroFireCSS result

Notes

A few of the things I learnt from this experiment:

Animation is not possible from Paint Worklet context

My original goal was to achieve an animated fire effect similar to this, via the PaintAPI. I discovered animation wasn't going to be possible due to requestAnimationFrame, setTimeout and setInterval not being available in the context of a Paint Worklet.

Paint Worklet's context is a subset of CanvasRenderingContext2D

The putImageData() method is not available on the context interface passed to the Paint Worklet's paint() method (according to MDN, the context passed to a Paint Worklet's paint method implements a subset of CanvasRenderingContext2D, as PaintRenderingContext2D). I therefore had to paint each pixel of the fire simulation one at a time, rather than via a single call to putImageData().

retro-fire-css's People

Contributors

dacre-denny avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.