sigmoid-line-classy.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 = 40 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' this.castSplit() } castSplit() { /* Generate the inner split and project all tips. The next function should be an updateSplit to edit each point to its corresponding fuction point. */ this.points = this.line.splitInner(this.count) } updateSplit() { let speed = 0.09 let t = this.tick * speed let deg = calculateAngle(this.points[0], this.points.last()) let p1 = 0 let amp2 = 1.12 let off1 = 0 // left offset. notice tip 0 let cos1 = 12 let cos2 = 5 const func = (e,i,a) => { let res = ( Math.cos(off1 + t + i) * cos1 -(p1 + Math.cos(t - i * amp2) * cos2) ) + p1 e.rotation = deg + (res < 0? 90: -90) e.radius = Math.abs(res) return e.getTip() } this.tips = this.points.map(func) } draw(ctx){ this.tick++; this.clear(ctx) if(this.line.a.wasDirty || this.line.b.wasDirty) { console.log('Dirty') this.castSplit() } 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-classy.js
filepath sigmoid-line-classy.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.'}