@graspologic/animation
Provides a set of utilities for animating @graspologic/renderer
primitives.
Usage
import { createAnimationUtil, AnimationUtil } from '@graspologic/animation'
import { GraphRenderer } from '@graspologic/renderer'
const utils: AnimationUtil = createAnimationUtil()
export function randomizeRenderer(renderer: GraphRenderer) {
for (const node of renderer.scene.nodes()) {
const x = Math.random()
const y = Math.random()
const z = Math.random()
utils.animatePosition(node, 'position', [x, y, z], 1000)
utils.animateColor(node, 'color', 0xff00bbff, 500)
}
for (const edge of renderer.scene.edges()) {
const sourceX = Math.random()
const sourceY = Math.random()
const sourceZ = Math.random()
const targetX = Math.random()
const targetY = Math.random()
const targetZ = Math.random()
utils.animatePosition(
edge,
'sourcePosition',
[sourceX, sourceY, sourceZ],
2000,
)
utils.animatePosition(edge, 'targetPosition', [targetX, targetY, targetZ])
}
}
See the API documentation or examples for additional examples.