brownian-point.js

total 0
used 0
limit 0
/* title: Brownian Within a Point categories: brownian random files: head point stage mouse dragging stroke ../point_src/random.js --- Plot a random point within a location. ``` xy = random.within(point, max=.5) ``` */ class MainStage extends Stage { canvas = 'playspace' updateSpeed = 10 mounted(){ this.modu = 0 this.pin = this.center.copy().update({radius: 200}) this.point = new Point() this.dragging.add(this.pin) addControl('updateSpeed', { field: 'range' , label: 'update speed' , step: 1 , max: 200 , stage: this , onchange(ev) { /*slider changed. */ let sval = ev.currentTarget.value this.stage.updateSpeed = parseInt(Math.sqrt(this.max)*2 + 1) - parseInt(Math.sqrt(sval)*2) } }) } draw(ctx) { this.clear(ctx) this.modu += 1 this.modu % this.updateSpeed == 0 && this.updateWalker() this.pin.pen.fill(ctx, '#222255') this.point.pen.fill(ctx, '#ddd') } updateWalker(max=.5) { this.point.xy = random.within(this.pin, max) } } stage = MainStage.go(/*{ loop: true }*/)
Run
Meta Data
title Brownian Within a Point
imports ()
files ('head', 'point', 'stage', 'mouse', 'dragging', 'stroke', '../point_src/random.js')
unused_keys ()
unknown_keys ('categories',)
categories ['brownian', 'random']
filepath_exists True
path brownian-point.js
filepath brownian-point.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/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/random.js')
markdown {'html': '<p>Plot a random point within a location.</p>\n<p><code>xy = random.within(point, max=.5)</code></p>', 'content': 'title: Brownian Within a Point\ncategories: brownian\n random\nfiles:\n head\n point\n stage\n mouse\n dragging\n stroke\n ../point_src/random.js\n---\n\nPlot a random point within a location.\n\n```\n xy = random.within(point, max=.5)\n```'}