Created
May 29, 2018 14:29
-
-
Save polyclick/cd193b2b321097555810c911ff938dd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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