elbow-2.js

total 0
used 0
limit 0
/* title: Elbow Constraints category: constraints files: head point stroke ../point_src/point-content.js pointlist mouse distances dragging ../point_src/functions/clamp.js ../point_src/mirror.js ../point_src/stage.js ../point_src/text/label.js ../point_src/intersections.js ../point_src/constrain-distance.js --- An elbow contraint ensures a target point is _connected_ to another point, at a distance of the two radii. point.constraint.elbow(other) It's called an elbow, as there will always be an intersection at the max distance. Similar to rings bound at the edge. Synonymous to: let pA = this.endPoint let pB = this.primaryPoint pA.leash(pointB, (pB.radius + pA.radius) - .01) pA.avoid(pointB, Math.abs(pB.radius - pA.radius) + .01) */ class MainStage extends Stage { canvas='playspace' mounted(){ this.endPoint = new Point({x:200,y:200, radius:90}) this.primaryPoint = new Point({x:390,y:240, radius:130}) this.dragging.addPoints(this.endPoint, this.primaryPoint) this.events.wake() } draw(ctx){ this.clear(ctx) this.endPoint.constraint.elbow(this.primaryPoint) let i2 = this.endPoint.intersections.of(this.primaryPoint) // let i2 = getCircleCircleIntersections(this.endPoint, this.primaryPoint) if(i2.length > 0) { /* draw (quietly) the ignored point. */ Point.from(i2[1]).pen.fill(ctx, '#332233') } this.endPoint.pen.indicator(ctx, {color: '#222'}) this.primaryPoint.pen.indicator(ctx) if(i2.length > 0) { this.endPoint.pen.line(ctx, i2[0], 'red') this.primaryPoint.pen.line(ctx, i2[0], 'red') Point.from(i2[0]).pen.fill(ctx, '#CC00BB') } } } ;stage = MainStage.go();
Run
Meta Data
title Elbow Constraints
imports ()
files ('head', 'point', 'stroke', '../point_src/point-content.js', 'pointlist', 'mouse', 'distances', 'dragging', '../point_src/functions/clamp.js', '../point_src/mirror.js', '../point_src/stage.js', '../point_src/text/label.js', '../point_src/intersections.js', '../point_src/constrain-distance.js')
unused_keys ()
unknown_keys ('category',)
category ['constraints']
filepath_exists True
path elbow-2.js
filepath elbow-2.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/setunset.js', '../point_src/stroke.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/events.js', '../point_src/automouse.js', 'distances', '../point_src/functions/clamp.js', '../point_src/distances.js', '../point_src/protractor.js', '../point_src/text/beta.js', '../point_src/dragging.js', '../point_src/mirror.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/text/label.js', '../point_src/intersections.js', '../point_src/constrain-distance.js')
markdown {'html': "<p>An elbow contraint ensures a target point is <em>connected</em> to another point, at\na distance of the two radii.</p>\n<pre><code> point.constraint.elbow(other)\n</code></pre>\n<p>It's called an elbow, as there will always be an intersection at the max distance.\nSimilar to rings bound at the edge.</p>\n<p>Synonymous to:</p>\n<pre><code>let pA = this.endPoint\nlet pB = this.primaryPoint\n\npA.leash(pointB,\n (pB.radius + pA.radius) - .01)\npA.avoid(pointB,\n Math.abs(pB.radius - pA.radius) + .01)\n</code></pre>", 'content': "title: Elbow Constraints\ncategory: constraints\nfiles:\n head\n point\n stroke\n ../point_src/point-content.js\n pointlist\n mouse\n distances\n dragging\n ../point_src/functions/clamp.js\n ../point_src/mirror.js\n ../point_src/stage.js\n ../point_src/text/label.js\n ../point_src/intersections.js\n ../point_src/constrain-distance.js\n---\n\nAn elbow contraint ensures a target point is _connected_ to another point, at\na distance of the two radii.\n\n point.constraint.elbow(other)\n\nIt's called an elbow, as there will always be an intersection at the max distance.\nSimilar to rings bound at the edge.\n\nSynonymous to:\n\n let pA = this.endPoint\n let pB = this.primaryPoint\n\n pA.leash(pointB,\n (pB.radius + pA.radius) - .01)\n pA.avoid(pointB,\n Math.abs(pB.radius - pA.radius) + .01)"}