Giter Club home page Giter Club logo

botb-svg-factory-animation's Introduction

factory svg animation

for battle of the bits major "GraphX"

The root of this repo contains the HTML version of this animation, the builds directory contains both minified and non-minified versions of the SVG file.

Note

<script> and <style> are both in the SVG 1.1 specification and are perfectly reasonable tags to use on SVG graphics to be viewed on web browsers. While many other image viewers may have issues with the animated part of this SVG file, it was intended from the start that this entry would only be viewed in web browsers, since only recent web browsers have full implementations of the SVG spec.

Description

All SVG elements/assets made in Inkscape, with some minor editing (such as ids of elements), with CSS and JS code added later. Animations are made using CSS3 keyframes/transitions and are controlled by the script which mostly involves resetting certain animated elements and setting random colour etc.

All animations are initially defined as CSS only keyframe animations which run once at the start when the file is first loaded, however using an "animationend" event listener on a dummy animation object which acts as a counter when most of the animations should be reset.

el.style.animation = "none";
el.clientHeight;
el.style.animation = null;

This code is used to reset the animation of one element by first overwriting its pre-defined animation property with "none" and then "reflowing" the element by computing its clientHeight property which all SVG objects have. Finally, removing the animation: none property from the element makes the animation property return to its pre-defined state.

After the dummy animation is over and the "animationend" event fires, predefined elements in the array animatedObjects and pistonObjects are queried, found and the reset function applied, which starts the animation all over again, albeit with different CSS properties (such as changing fill values).

The sequence of animations themselves are controlled by CSS animation delay, running multiple animations on the same element which is supported in CSS3.

Separate Animations

  • The conveyor belts are animated by controlling the stroke-dashoffset property which is controllable via CSS, which replays infinitely. This works as the belt itself is a path with a dash applied.

  • All the cube/piston animations are carefully sequenced so that they align correctly on time, which was a little bit difficult to do as the only thing you can control with CSS animations is the timing, delay and the animation itself.

  • The pixelisation filter effect is created using two separate objects, the original note object and the already pixelised version, where a CSS animation changes the opacity/visibility of both objects at the same time, making it appear as if they changed as the note moves through the "filter". I used the steps() function to instantly change the opacity/visibility of the note objects, instead of gradually (which would happen using a timing function such as linear or ease-in-out).

botb-svg-factory-animation's People

Contributors

argarak avatar

Watchers

 avatar  avatar

botb-svg-factory-animation's Issues

final version

must todos:

  • fix piston and cube animation sync
  • allow for multiple cubes to be animated at once
  • change delayed css3 animation sequence to class-based control via js
  • cube -> note machine
  • pixelisation filter at final stage
  • deleting cube node at the end off screen to minimise resource usage

optional todos:

  • cube fill colours chosen randomly (or from list)
  • colour machine sliders corresponding to actual rgb values

possible additions:

  • laser cutting animation
  • plastic pellet melting animation

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.