rel-function.js

total 0
used 0
limit 0
/* title: Rel Function categories: relative functions files: head ../point_src/point-content.js pointlist point mouse dragging stroke ../point_src/functions/clamp.js ../point_src/functions/rel.js stage ../point_src/split.js ../point_src/random.js --- The `rel()` function provides _relative_ offset to values, such as the `point.x`. In this example the center point is copied, and offset by `rel(-200)`. */ const boundCaller = function(func) { /* return a function to call the _given_ function. This allows a _dynamic_ value, called every update. For example, ensure the `y` value of a point is the same as `x`: a.y = boundCaller((p, k) => p.x) */ return function relCaller(p, k) { console.log('Call once') return func.bind(p) } } class MainStage extends Stage { canvas='playspace' mounted(){ let offsetValue = -200 this.center.radius = 40 let a = this.a = this.center.copy() a.x = rel(offsetValue) this.dragging.add(a) a.y = boundCaller((p, k) => this.center.y + offsetValue) } draw(ctx){ this.clear(ctx) this.a.pen.fill(ctx, `hsl(90deg 100% 30%)`) this.center.pen.fill(ctx, `hsl(90deg 10% 10%)`) } } ;stage = MainStage.go();
Run
Meta Data
title Rel Function
imports ()
files ('head', '../point_src/point-content.js', 'pointlist', 'point', 'mouse', 'dragging', 'stroke', '../point_src/functions/clamp.js', '../point_src/functions/rel.js', 'stage', '../point_src/split.js', '../point_src/random.js')
unused_keys ()
unknown_keys ('categories',)
categories ['relative', 'functions']
filepath_exists True
path rel-function.js
filepath rel-function.js
clean_files ('../point_src/core/head.js', '../point_src/compass.js', '../point_src/center.js', '../point_src/point-content.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/pointpen.js', '../point_src/pointdraw.js', '../point_src/relative-xy.js', '../point_src/pointcast.js', '../point_src/point.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/functions/rel.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/split.js', '../point_src/random.js')
markdown {'html': '<p>The <code>rel()</code> function provides <em>relative</em> offset to values, such as the <code>point.x</code>.</p>\n<p>In this example the center point is copied, and offset by <code>rel(-200)</code>.</p>', 'content': 'title: Rel Function\ncategories: relative\n functions\nfiles:\n head\n ../point_src/point-content.js\n pointlist\n point\n mouse\n dragging\n stroke\n ../point_src/functions/clamp.js\n ../point_src/functions/rel.js\n stage\n ../point_src/split.js\n ../point_src/random.js\n---\n\nThe `rel()` function provides _relative_ offset to values, such as the `point.x`.\n\nIn this example the center point is copied, and offset by `rel(-200)`.'}