sigmoid-line-example.js

total 0
used 0
limit 0
/* title: Sigmoid Line categories: line sigmoid files: head point pointlist stage mouse dragging stroke ../point_src/split.js ../point_src/random.js ../point_src/curve-extras.js ../point_src/math.js --- sigmoid function line. + flat line + split() + sigmoid function + tip project + draw a line This can draw complex or simple waves. --- Intersect at the perpendicular for sampling the line. */ class MainStage extends Stage { // canvas = document.getElementById('playspace'); canvas = 'playspace' mounted(){ let count = this.count = 22 let multiplier = [300, 200, null, 0] let offset = [100, 100, 10, 0] // this.points = PointList.generate.random(count, multiplier, offset) let lpoints = [new Point(100, 100), new Point(500, 100)] this.line = new Line(...lpoints) this.dragging.add(...this.line.points) this.tick = 0 } firstDraw(ctx) { ctx.lineCap = 'round' } updateSplit() { let t = this.tick * .06 let deg = calculateAngle(...this.line.points) let p1 = 30 let amp = 4 let cos1 = 12 let cos2 = 10 const func = (e,i,a) => { let res = ( Math.cos(3 + t + i) * cos1 -(p1 + Math.cos(t - i * amp) * cos2) ) + p1 e.rotation = deg + ((res < 0) ? 90: -90) e.radius = Math.abs(res) } this.points = this.line.splitInner(this.count) let pl = this.points.map((e,i,a) => { func(e,i,a) return e.project() }) this.tips = pl; } draw(ctx){ this.tick++; this.clear(ctx) this.updateSplit() let col = 'purple'; let width = 2 this.line.render(ctx, {color: '#111', width}) // this.points.pen.indicator(ctx) // this.points.pen.lines(ctx, col, width) // this.tips?.pen.line(ctx, col, width) this.tips?.pen.quadCurve(ctx, col) } } stage = MainStage.go(/*{ loop: true }*/)
Run
Meta Data
title Sigmoid Line
imports ()
files ('head', 'point', 'pointlist', 'stage', 'mouse', 'dragging', 'stroke', '../point_src/split.js', '../point_src/random.js', '../point_src/curve-extras.js', '../point_src/math.js')
unused_keys ()
unknown_keys ('categories',)
categories ['line', 'sigmoid']
filepath_exists True
path sigmoid-line-example.js
filepath sigmoid-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-hooks.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/setunset.js', '../point_src/stroke.js', '../point_src/split.js', '../point_src/random.js', '../point_src/curve-extras.js', '../point_src/math.js')
markdown {'html': '<p>sigmoid function line.</p>\n<ul>\n<li>flat line</li>\n<li>split()</li>\n<li>sigmoid function</li>\n<li>tip project</li>\n<li>draw a line</li>\n</ul>\n<p>This can draw complex or simple waves.</p>\n<hr />\n<p>Intersect at the perpendicular for sampling the line.</p>', 'content': 'title: Sigmoid Line\ncategories: line\n sigmoid\nfiles:\n head\n point\n pointlist\n stage\n mouse\n dragging\n stroke\n ../point_src/split.js\n ../point_src/random.js\n ../point_src/curve-extras.js\n ../point_src/math.js\n---\n\nsigmoid function line.\n\n+ flat line\n+ split()\n+ sigmoid function\n+ tip project\n+ draw a line\n\nThis can draw complex or simple waves.\n\n---\n\nIntersect at the perpendicular for sampling the line.'}