little-measure.js

total 0
used 0
limit 0
/* title: Little Measure. categories: measurement files: head stage point pointlist dragging stroke mouse ../point_src/text/beta.js --- A simple example for presenting _measurements_ at scale, similar to a map scale. The measure point represents the scale bar. The primary point presents its factored radius, relative to the measurement. */ class MainStage extends Stage { canvas = 'playspace' mounted() { this.measure = new Point(500, 500, 20) this.point = new Point(150, 150, 100) this.dragging.add(this.measure, this.point) /* Base unit of 1, assuming M, or CM, it doesn't matter... it's 1 of the them. */ this.base = 1 // m } firstDraw(ctx) { ctx.fillStyle = 'red' ctx.font = '400 16px arial' } compute() { /* One compute size. */ let one = (1 / this.base) * this.measure.radius // console.log('one', one) let size = this.point.radius / one this.point.text.value = `${size.toFixed(2)}x == ${(this.point.radius * size).toFixed(2)}` } draw(ctx) { this.clear(ctx); this.compute() this.point.pen.circle(ctx, undefined, 'red') this.point.text.fill(ctx) this.measure.pen.indicator(ctx, undefined, 'pink') let mr = this.measure.radius.toFixed() let mt = `${this.base}x (${mr}px)` this.measure.text.fill(ctx, mt) // this.measure.text.label(ctx, 'words') } } stage = MainStage.go()
Run
Meta Data
title Little Measure.
imports ()
files ('head', 'stage', 'point', 'pointlist', 'dragging', 'stroke', 'mouse', '../point_src/text/beta.js')
unused_keys ()
unknown_keys ('categories',)
categories ['measurement']
filepath_exists True
path little-measure.js
filepath little-measure.js
clean_files ('../point_src/core/head.js', '../point_src/stage-hooks.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.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/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/events.js', '../point_src/automouse.js')
markdown {'html': '<p>A simple example for presenting <em>measurements</em> at scale, similar to a map scale.\nThe measure point represents the scale bar. The primary point presents its factored radius,\nrelative to the measurement.</p>', 'content': 'title: Little Measure.\ncategories: measurement\nfiles:\n head\n stage\n point\n pointlist\n dragging\n stroke\n mouse\n ../point_src/text/beta.js\n---\n\nA simple example for presenting _measurements_ at scale, similar to a map scale.\nThe measure point represents the scale bar. The primary point presents its factored radius,\nrelative to the measurement.'}