brownian-point-blur.js

total 0
used 0
limit 0
/* title: Brownian Blur categories: brownian random blur files: head point stage mouse dragging stroke ../point_src/random.js --- In this example we simply turn off the `clear` call to allow allow a persistent canvas. For each step (`stage.count`) performs hundreds of randomly positioned points, using the `random.within` function. As this function uses `Math.random` roughly 36k times per second, we gain a good insight to _how random_ the random function is. If this function was **truly random** the image should resolve to a pure sphere. However you may to see a persistent pattern with micro gaps (undrawn dark spots). The gaps show the random function doesn't generate _some_ numbers. Given the image stabilises over time (it essentially stops changing) shows the random repeats the same numbers after a certain period. ``` xy = random.within(point, max=.5) ``` */ class MainStage extends Stage { canvas = 'playspace' updateSpeed = 1 mounted(){ this.count = 1000 this.pixelColor = '#fff' this.pin = this.center.copy().update({radius: 200}) this.point = new Point({radius: .3}) 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) } }) } firstDraw(ctx) { this.pin.pen.fill(ctx, '#222255') ctx.fillStyle = this.pixelColor } draw(ctx) { // this.clear(ctx) let count = this.count; let p = this.point for(var i = count - 1; i >= 0; i--) { this.updateWalker() ctx.beginPath() p.draw.arc(ctx, p.radius) ctx.fill() } // this.point.pen.fill(ctx, this.pixelColor) } updateWalker(max=.5) { this.point.xy = random.within(this.pin, max) } } stage = MainStage.go({ loop: true })
Run
Meta Data
title Brownian Blur
imports ()
files ('head', 'point', 'stage', 'mouse', 'dragging', 'stroke', '../point_src/random.js')
unused_keys ()
unknown_keys ('categories',)
categories ['brownian', 'random', 'blur']
filepath_exists True
path brownian-point-blur.js
filepath brownian-point-blur.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>In this example we simply turn off the <code>clear</code> call to allow allow a persistent\ncanvas. For each step (<code>stage.count</code>) performs hundreds of randomly positioned points,\nusing the <code>random.within</code> function.</p>\n<p>As this function uses <code>Math.random</code> roughly 36k times per second, we gain a good insight to\n<em>how random</em> the random function is.</p>\n<p>If this function was <strong>truly random</strong> the image should resolve to a pure sphere.\nHowever you may to see a persistent pattern with micro gaps (undrawn dark spots).</p>\n<p>The gaps show the random function doesn't generate <em>some</em> numbers.\nGiven the image stabilises over time (it essentially stops changing) shows the random\nrepeats the same numbers after a certain period.</p>\n<p><code>xy = random.within(point, max=.5)</code></p>", 'content': "title: Brownian Blur\ncategories: brownian\n random\n blur\nfiles:\n head\n point\n stage\n mouse\n dragging\n stroke\n ../point_src/random.js\n---\n\nIn this example we simply turn off the `clear` call to allow allow a persistent\ncanvas. For each step (`stage.count`) performs hundreds of randomly positioned points,\nusing the `random.within` function.\n\nAs this function uses `Math.random` roughly 36k times per second, we gain a good insight to\n_how random_ the random function is.\n\nIf this function was **truly random** the image should resolve to a pure sphere.\nHowever you may to see a persistent pattern with micro gaps (undrawn dark spots).\n\nThe gaps show the random function doesn't generate _some_ numbers.\nGiven the image stabilises over time (it essentially stops changing) shows the random\nrepeats the same numbers after a certain period.\n\n```\nxy = random.within(point, max=.5)\n```"}