starfield-example.js

total 0
used 0
limit 0
/* title: Simple Starfield categories: minimal starfield files: head point pointlist stroke stage mouse dragging ../point_src/random.js ../point_src/screenwrap.js ../point_src/velocity.js --- A simple starfield, with recycled points and general _direction_ and _speed_. */ class MainStage extends Stage { canvas = 'playspace' mounted() { let pin = new Point(0, 0, 1, 0) let pin2 = new Point(0, 0, .1, 0) this.points = PointList.generate.random(100, [1200, 800], pin) this.pins = PointList.generate.random(20, [1200, 800], pin2) this.reactor = new VelocityReactor() this.reactor.points = this.points // the direction of travel, applied to each points velocity. let direction = new Point(3, -.35) // this.reactor.randomize() this.points.forEach(p=>{ // circle plot area // p.xy = random.within(pin, 600) p.velocity.set(direction.multiply(p.radius * -.05)) let light = 80 * (p.radius * .25) p.color = `hsl(200, 70%, ${light}%)` p.radius *= 3 // turn to direction of travel faceVelocity(p) }) } draw(ctx){ this.clear(ctx) this.reactor.step() this.points.forEach(p=>this.screenWrap.perform(p)) this.pins.pen.fill(ctx, '#666') this.points.pen.lines(ctx) // this.points.pen.indicator(ctx) // this.points.pen.fill(ctx, 'green') } } stage = MainStage.go(/*{ loop: true }*/)
Run
Meta Data
title Simple Starfield
imports ()
files ('head', 'point', 'pointlist', 'stroke', 'stage', 'mouse', 'dragging', '../point_src/random.js', '../point_src/screenwrap.js', '../point_src/velocity.js')
unused_keys ()
unknown_keys ('categories',)
categories ['minimal', 'starfield']
filepath_exists True
path starfield-example.js
filepath starfield-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/setunset.js', '../point_src/stroke.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/random.js', '../point_src/screenwrap.js', '../point_src/velocity.js')
markdown {'html': '<p>A simple starfield, with recycled points and general <em>direction</em> and <em>speed</em>.</p>', 'content': 'title: Simple Starfield\ncategories: minimal\n starfield\nfiles:\n head\n point\n pointlist\n stroke\n stage\n mouse\n dragging\n ../point_src/random.js\n ../point_src/screenwrap.js\n ../point_src/velocity.js\n---\n\nA simple starfield, with recycled points and general _direction_ and _speed_.'}