motion-two-line.js

total 0
used 0
limit 0
/* title: Example categories: basic dragging files: head point pointlist stage mouse dragging ../point_src/random.js ../point_src/arc.js --- */ 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.dragging.add(this.point) this.tick = 0 this._last1 = this.point.copy() this._last0 = this.point.copy().subtract(20) } firstDraw(ctx) { // ctx.lineCap = 'round' ctx.strokeStyle = 'red' } draw(ctx){ this.tick++; this.clear(ctx) let p = this.point this.point.pen.circle(ctx, p.radius, p.color) ctx.lineCap = 'butt' if(this.tick % 20 == 0) { this._last1 = this._last0 this._last0 = this.point.copy() ctx.lineCap = 'round' this.point.x = random.int(100, 500) this.point.y = random.int(100, 500) } // let cap = this._last0.arc.to(this.point, this._last1) // if(cap) { // ctx.beginPath(); // ctx.strokeStyle = 'green' // ctx.arc(cap.cx, cap.cy, cap.radius, cap.startRadians, cap.toRadians, 1); // ctx.stroke(); // } // this._last0.pen.fill(ctx, 'red') this.point.pen.line(ctx, this._last0, '#DD0000', p.width) // this._last1.pen.fill(ctx, 'red') this._last1.pen.line(ctx, this._last0, '#550000', p.width) } } stage = MainStage.go(/*{ loop: true }*/)
Run
Meta Data
title Example
imports ()
files ('head', 'point', 'pointlist', 'stage', 'mouse', 'dragging', '../point_src/random.js', '../point_src/arc.js')
unused_keys ()
unknown_keys ('categories',)
categories ['basic', 'dragging']
filepath_exists True
path motion-two-line.js
filepath motion-two-line.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', '../point_src/arc.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 ../point_src/arc.js\n---'}