Skip to content

Instantly share code, notes, and snippets.

@polyclick
Created May 29, 2018 14:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save polyclick/cd193b2b321097555810c911ff938dd0 to your computer and use it in GitHub Desktop.
// difference between current and previous cursor position & distance
this.delta = pk.Vector.sub(this.lerped, this.plerped)
this.distance = this.delta.mag()
// paint repeatedly by interpolating the bristle’s stamp position over the course of distance
// then stamp the bristles texture onto the final render target by copying its pixels
let numDraws = this.distance || 1
for (let i = 0; i < numDraws; i++) {
let ipos = pk.Vector.lerp(this.plerped, this.lerped, i / numDraws)
this.bristles.position = new PIXI.Point(ipos.x, ipos.y)
this.pixi.renderer.render(this.bristles, this.target, false, null, false)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment