Thanks to visit codestin.com
Credit goes to github.com

Skip to content

trinketmage/sword

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sword.js

Version Downloads Issues

It's dangerous to go alone! Take this.

It's dangerous to go alone! Take this.

Getting started

npm i --save @trinketmage/sword

Mathematics

  • lerp: Linear interpolation.
  • angleToVector: Calculate a 2d vector on unit circle from an angle in degree.
  • vectorToAngle: Calculate an angle in degree from a 2d vector (with optional pivot).

3d

  • getScreenPos: Screen position (2d vector) of position (3d vector).
  • getFovHeigth: Get height of frustrum (y) at a specific depth (z).

glsl

  • stagger: glsl implementation of staggers
#pragma glslify: stagger = require(@trinketmage/sword/src/glsl/stagger)
  • backgroundCover: glsl UV calculation for background cover for fullscreen texture
#pragma glslify: backgroundCover = require(@trinketmage/sword/src/glsl/backgroundCover)

tsl

matrices

const rotatedUV = rotate2d(rotation).mul(uv);

responsive

  • responsive: homothetic helper to match two ratios
// example center an image
const res = responsive(ratio1, ratio2);
let st = uv().mul(res).add(res.oneMinus().mul(0.5));

sdf

  • sdBox: ..
  • sdRoundedBox: ..
  • sdCircle: ..
  • sdGlyph: render a glyph from a sdf/msdf texture
// render a glyph from an msdf atlas
// luv is local uv computed in geometry attribute
var sample = texture(atlas, luv);
var alpha = sdGlyph(sample);

arithmetic operators (to avoid conditionals)

  • notEqual: ..
  • greater: ..
  • lesser: ..
  • greaterEqual: ..
  • lesserEqual: ..
  • and: ..
  • or: ..
  • xor: ..
  • not: ..

Twitter

About

Javascript animation hero helpers kit

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •