motion-line-example.js

total 0
used 0
limit 0
/* title: Example categories: basic dragging files: head point pointlist stage mouse dragging ../point_src/random.js --- */ class MotionLerp { constructor(point){ this.point = point this._last = this.point.copy().subtract(20) this.tick = 0 } step(){ this.tick++; let p = this.point // this.point.draw.quadCurve(ctx, this._last) // ctx.stroke() // this.point.pen.quadCurve(ctx, this._last, p.color) this._last = this._last.lerp(p, .19) // this._last = p.copy() } drawLine(ctx) { let p = this.point p.pen.line(ctx, this._last, p.color, p.radius) } } class MainStage extends Stage { // canvas = document.getElementById('playspace'); canvas = 'playspace' mounted(){ this.point = new Point({x: 250, y: 150 , radius: 5, rotation: 45, color: 'green' }); this._last = this.point.copy().subtract(20) this.tick = 0 this.dragging.add(this.point) this.ml = new MotionLerp(this.point) } firstDraw(ctx) { // ctx.lineCap = 'round' ctx.strokeStyle = 'red' } draw(ctx){ // this.ml.tick++; this.clear(ctx) let p = this.point // this.point.draw.quadCurve(ctx, this._last) // ctx.stroke() // this.point.pen.quadCurve(ctx, this._last, p.color) // this.point.pen.line(ctx, this._last, p.color, p.radius) this.ml.step() // this.ml._last = this.ml._last.lerp(p, .5) // this._last = p.copy() this.point.pen.circle(ctx, p.radius, p.color); ctx.lineCap = 'butt' if(this.ml.tick % random.int(10,65) == 0) { ctx.lineCap = 'round' this.point.x = random.int(100, 500) this.point.y = random.int(100, 500) } this.ml.drawLine(ctx) } } stage = MainStage.go(/*{ loop: true }*/)
Run
Meta Data
title Example
imports ()
files ('head', 'point', 'pointlist', 'stage', 'mouse', 'dragging', '../point_src/random.js')
unused_keys ()
unknown_keys ('categories',)
categories ['basic', 'dragging']
filepath_exists True
path motion-line-example.js
filepath motion-line-example.js
clean_files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/compass.js', '../point_src/center.js', '../point_src/point-content.js', '../point_src/pointdraw.js', '../point_src/relative-xy.js', '../point_src/pointcast.js', '../point_src/point.js', '../point_src/pointlistdraw.js', '../point_src/pointlistgradient.js', '../point_src/pointlistshape.js', '../point_src/pointlistgenerator.js', '../point_src/unpack.js', '../point_src/pointlist.js', '../point_src/pointlistpen.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/events.js', '../point_src/automouse.js', '../point_src/functions/clamp.js', '../point_src/distances.js', '../point_src/protractor.js', '../point_src/text/beta.js', '../point_src/dragging.js', '../point_src/random.js')
markdown {'html': '', 'content': 'title: Example\ncategories: basic\n dragging\nfiles:\n head\n point\n pointlist\n stage\n mouse\n dragging\n ../point_src/random.js\n---'}