drawing-pad.js

total 0
used 0
limit 0
/* title: Drawing Pad category: drawing files: head point stroke pointlist mouse dragging ../point_src/distances.js ../point_src/functions/clamp.js ../point_src/functions/rel.js ../point_src/stage.js ../point_src/gradient.js --- A simple drawing pad. */ class MainStage extends Stage { canvas='playspace' mounted(){ this.mp = new Point(100, 100, 3) this.createGradient() this.dragging.add( this.gradPointA, this.gradPointB, ) } createGradient() { let c = this.center this.gradPointA = c.copy().update({ x:rel(-250), y:rel(-200), radius: 20, color:"hsl(299deg 62% 44%)"}) this.gradPointB = c.copy().update({ x:rel(200), y:rel(250), radius: 20, color: "hsl(244deg 71% 56%)"}) this.g = (new Gradient).linear(this.gradPointA, this.gradPointB) this.g.addStops({ 0: this.gradPointA, 1: this.gradPointB }) return this.g; } onMousedown() { this.penDown = true } onMouseUp() { this.penDown = false } onMousemove(ev) { this.mp.xy = Point.from(ev) } draw(ctx){ // this.clear(ctx) this.g.linear() // refresh hack. let grad = this.g.getObject(ctx) if(this.penDown) { this.mp.pen.line(ctx, this.oldMp, grad, 4) } this.oldMp = this.mp.copy() } } ;stage = MainStage.go();
Run
Meta Data
title Drawing Pad
imports ()
files ('head', 'point', 'stroke', 'pointlist', 'mouse', 'dragging', '../point_src/distances.js', '../point_src/functions/clamp.js', '../point_src/functions/rel.js', '../point_src/stage.js', '../point_src/gradient.js')
unused_keys ()
unknown_keys ('category',)
category ['drawing']
filepath_exists True
path drawing-pad.js
filepath drawing-pad.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/setunset.js', '../point_src/stroke.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/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/functions/rel.js', '../point_src/stage-hooks.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/gradient.js')
markdown {'html': '<p>A simple drawing pad.</p>', 'content': 'title: Drawing Pad\ncategory: drawing\nfiles:\n head\n point\n stroke\n pointlist\n mouse\n dragging\n ../point_src/distances.js\n ../point_src/functions/clamp.js\n ../point_src/functions/rel.js\n ../point_src/stage.js\n ../point_src/gradient.js\n---\n\nA simple drawing pad.'}