Giter VIP home page Giter VIP logo

animlib's Introduction

animlib

Library for recording browser-based animations.

Builds heavily on d3. Recording of animations is performed using library puppeteer of Node.js, ffmpeg, and some trickery dealing with d3-transitions and internal timer of the browser (inspired by examples in here and here).

Used mainly for my own projects. That is, some parts of the program can be sloppily written. Usage at one's own risk!

Copyright (c) 2020 NoobQuant/Ville Voutilainen.

Dependencies

Animations

  • d3 v5.15.1. Stored under src/dependencies/d3.
  • d3-xyzoom v1.5.0. Stored under src/dependencies/d3-xyzoom.

Recording

Have following installed on your computer:

How to use:

  • Create project folder, e.g. /projects/my_project or somewhere outside the repo.
  • For a new scene, copy a template src/template.hrml, move it project folder and rename file, e.g. <my_scene.html>.
  • Specify js-import paths in scene file. Paths are relative to scene file path. If project folder is located in path /projects/my_project, then paths are already correctly specified.
  • Set up local server on a drive with access to project folder.
  • Code the scene. Examples given in folder mwes/. Inspect in browser that everything works.
  • Once done, make use document.URL.includes('my_scene') to hack browser internal timer (file name is included for sure in the document URL).
  • In record.ps1, specify paths
    • pathToAnimaLib: Full path to animlib repo on local drive.
    • pathToVids: Full path to local folder where recorded videos are put.
    • pathToPuppeteer: Full path path to node.js modules local folder node_modules/puppeteer. Puppeteer is used form this folder.
    • seconds: How many secons to record.
    • projectPathLocalHost: localhost URL to scene file.
    • outputVidName: Name for output video.
  • Restart localhost connection to be sure.
  • Set paths record.ps1. Run record.ps1 e.g. in PowerShell ISE.

Documentation

Documentation forthcoming. Run jsdoc -c jsdoc.json.

animlib's People

Contributors

vvoutilainen avatar

Watchers

James Cloos avatar  avatar

animlib's Issues

Selections into AnimObject scope

All methods bound to an AnimObject are global selection: d3.select(..). This is unwanted -> better to have selection in the coresponding AnimObject scope to avoid removing objects by accident. Further, it is redundant to have a global selection bound to each AnimObject. This deals with objects bound to AnimObject.

Correction would look something like this:
d3.select("#myanimobject).select("#objectid")

AnimObject definition

AnimObject is a group bound to either bgsvg or another AnimObject. It has a unique ID. Within AnimObject class the group can be referenced via this.ao.

There are two attribute objects attached to AnimObject: attrVar and attrFix.

attrVar: updateable attributes:

  • General
    • pos
    • opacity
    • scale
    • data
  • Inner space related
    • xRange
    • yRange
    • xDomain
    • yDomain
    • xScale
    • yScale
    • xScaleType
    • yScaleType

Position to NaN by default

Position by transform should be set to NaN/None by default. Then only if position is determined will transform take place. If not, then position is not changed by transformation, allowing those objects that don't need it to be called upon like the rest, without disabling the position transform explicitly.

bug_zoom1

From commit 298dde6 onwards: weird truncating behavior when zooming svg and rescaling axes on the svg. Original line on the axes gets truncated, although a new line drawn on the axes after re-scaling appears just fine.

See bugs/bug_zoom1.html.

Updating multiple plot object

In b3a7e65: see mwe_plot. Multiple line object cannot be updated with the axes. This is curable with a simple loop, however there is a deeper problem how info of multiple line objects are stored under the plot. Now it assumes that plot can have only one line data stored to ; this needs to be changed also. So far done for line and scatter, need to still update for

  • histogram
  • bar

We could probably merge different plot object update functions (e.g. _UpdateScatterParams) into one.

Zooming out current canvas

Embedding svgs within svg offers possibility to zoom out certain block. However, one cannot continue drawing from the resized canvas to another. Would be nice to be able to zoom out "active" canvas so that we can continue drawing "as is" after zoom-out.

Make Svg() have ranges

Should have xRange and yRange instead of width and height. This ought to come automatically when AnimObject gets ranges.

Text transition

Capability of transforming text snippet into another via some sort of animation. E.g. "cat" -> "dog".

pos in AnimObject

Change position pos s.t. updates are passed into Update() and then attrVar.pos changes.

New data on zoomed axes use non-zoomed scales

When a new line is drawn on zoomed axes, they are drawn using old non-zoomed scales. This messes up position and axes ticks when they get updated (set based on non-zoomed scales).

See bug_zoom2.html.

Add clip area to svgs

Add clip area to svgs so that anything outside them gets clipped. Ought to happen automatically from Animobject.

Arrow/Path with svg paths

A few bugs when drawing Arrows/Paths with svg paths: arrow head is misplaced and/or shaft is in wrong place relative to what AnimObject position is.

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.