spreadline-2.js

total 0
used 0
limit 0
/* --- title: Spread Line src_dir: ../point_src/ files: ../point_src/core/head.js point pointlist mouse dragging stroke ../point_src/stage.js ../point_src/split.js ../point_src/jiggle.js ../point_src/random.js --- */ class SpreadLines extends PointList { static spawn(generalRadius=20, hue) { let items = PointList.generate.random(20, [300, 200, null, 0], [100, 100, 10, 0] ) items.each.hue = hue; items.each.z = (p) => Math.random() items.each.radius = (p) => generalRadius * p.z items.forEach((p)=>{ let v = (1 - p.z) * random.float(.1, .4)//Math.random() p.jiggler.options.speedReducer = v p.jiggler.options.height = 10 * p.z }) return SpreadLines.from(items) // return items } render(ctx, minSaturation=10 /*percent*/, generalLineWidth=4) { this.forEach(function(p){ let hue = p.hue - (100 * p.z) /* Build a saturation value from the Z */ let saturation = ( (50 * (1-p.z) ) + minSaturation) let cleanSat = clamp(70-saturation, 10, 60).toFixed(1) let color = `hsl(${hue}deg 100% ${cleanSat}%)` p.jiggler.step() let pp = p.jiggler.point pp.split(2).pen.line(ctx, { color , width: generalLineWidth * p.z }) }) } } class MainStage extends Stage { canvas='playspace' mounted(){ this.makePl() let a = this.a = new Point({x:200,y:200, radius: 50, rotation: 0}) this.dragging.add(a) this.events.wake() } onClick(){ this.makePl() } makePl() { let generalRadius = 40 let hue = (Math.random() * 360).toFixed(1) this.pl = SpreadLines.spawn(generalRadius, hue) } draw(ctx){ this.clear(ctx) let generalLineWidth = 5 let minSaturation = 10 /*percent*/ ctx.lineCap = "round" this.pl.render(ctx, minSaturation, generalLineWidth) } } ;stage = MainStage.go();
Run
Meta Data
title Spread Line
imports ()
files ('../point_src/core/head.js', 'point', 'pointlist', 'mouse', 'dragging', 'stroke', '../point_src/stage.js', '../point_src/split.js', '../point_src/jiggle.js', '../point_src/random.js')
unused_keys ()
unknown_keys ('src_dir',)
src_dir ['../point_src/']
filepath_exists True
path spreadline-2.js
filepath spreadline-2.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/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/setunset.js', '../point_src/stroke.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/split.js', '../point_src/jiggle.js', '../point_src/random.js')
markdown {'html': '', 'content': '---\ntitle: Spread Line\nsrc_dir: ../point_src/\nfiles:\n ../point_src/core/head.js\n point\n pointlist\n mouse\n dragging\n stroke\n ../point_src/stage.js\n ../point_src/split.js\n ../point_src/jiggle.js\n ../point_src/random.js\n---'}