leash-track-points.js

total 0
used 0
limit 0
/* title: One-way Leash categories: constraints files: ../point_src/core/head.js ../point_src/pointpen.js ../point_src/pointdraw.js ../point_src/math.js ../point_src/extras.js ../point_src/point-content.js ../point_src/pointlistpen.js ../point_src/pointlist.js ../point_src/point.js ../point_src/stage.js ../point_src/events.js ../point_src/automouse.js ../point_src/distances.js dragging ../point_src/setunset.js ../point_src/stroke.js ../point_src/constrain-distance.js --- A point can "track" or "leash" to another point. In this setup it works in one-direction. Where the _locked point_ can pull the secondary point, but will stay locked when pulled. + `leash()` ensures the secondary point is _within_ a set distance. + `track()` locks the secondary point at a target distance. */ class MainStage extends Stage { // canvas = document.getElementById('playspace'); canvas = 'playspace' mounted(){ this.points = new PointList( new Point(250, 150, 10) , new Point(400, 320, 7) , new Point(450, 520, 10) , new Point(490, 490, 7) ) this.dragging.add(...this.points) } draw(ctx){ this.clear(ctx) let mouse = Point.mouse.position // point[3] _tracks_ point[2] this.points[3].track(this.points[2], 200) // point[1] _leashes to_ point[0] this.points[1].leash(this.points[0], 200) this.points[1].pen.indicator(ctx) this.points[3].pen.indicator(ctx) this.points[0].pen.fill(ctx, '#33aadd') this.points[2].pen.fill(ctx, '#33aadd') } } stage = MainStage.go(/*{ loop: true }*/)
Run
Meta Data
title One-way Leash
imports ()
files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/math.js', '../point_src/extras.js', '../point_src/point-content.js', '../point_src/pointlistpen.js', '../point_src/pointlist.js', '../point_src/point.js', '../point_src/stage.js', '../point_src/events.js', '../point_src/automouse.js', '../point_src/distances.js', 'dragging', '../point_src/setunset.js', '../point_src/stroke.js', '../point_src/constrain-distance.js')
unused_keys ()
unknown_keys ('categories',)
categories ['constraints']
filepath_exists True
path leash-track-points.js
filepath leash-track-points.js
clean_files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/math.js', '../point_src/extras.js', '../point_src/compass.js', '../point_src/center.js', '../point_src/point-content.js', '../point_src/pointlistpen.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/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/distances.js', '../point_src/functions/clamp.js', '../point_src/protractor.js', '../point_src/text/beta.js', '../point_src/dragging.js', '../point_src/setunset.js', '../point_src/stroke.js', '../point_src/constrain-distance.js')
markdown {'html': '<p>A point can "track" or "leash" to another point. In this setup it works in\none-direction. Where the <em>locked point</em> can pull the secondary point, but will\nstay locked when pulled.</p>\n<ul>\n<li><code>leash()</code> ensures the secondary point is <em>within</em> a set distance.</li>\n<li><code>track()</code> locks the secondary point at a target distance.</li>\n</ul>', 'content': 'title: One-way Leash\ncategories: constraints\nfiles:\n ../point_src/core/head.js\n ../point_src/pointpen.js\n ../point_src/pointdraw.js\n ../point_src/math.js\n ../point_src/extras.js\n ../point_src/point-content.js\n ../point_src/pointlistpen.js\n ../point_src/pointlist.js\n ../point_src/point.js\n ../point_src/stage.js\n ../point_src/events.js\n ../point_src/automouse.js\n ../point_src/distances.js\n dragging\n ../point_src/setunset.js\n ../point_src/stroke.js\n ../point_src/constrain-distance.js\n---\n\nA point can "track" or "leash" to another point. In this setup it works in\none-direction. Where the _locked point_ can pull the secondary point, but will\nstay locked when pulled.\n\n+ `leash()` ensures the secondary point is _within_ a set distance.\n+ `track()` locks the secondary point at a target distance.'}