angle-point.js

total 0
used 0
limit 0
/* --- title: Calculate Angles category: angles files: ../point_src/core/head.js ../point_src/pointpen.js ../point_src/pointdraw.js ../point_src/setunset.js ../point_src/stroke.js ../point_src/point-content.js ../point_src/pointlist.js ../point_src/point.js ../point_src/protractor.js ../point_src/events.js ../point_src/automouse.js ../point_src/distances.js ../point_src/dragging.js ../point_src/functions/clamp.js ../point_src/mirror.js ../point_src/stage.js ../point_src/text/label.js ../point_src/text/alpha.js --- This example presents a the angle value between two points (their rotation). */ class MainStage extends Stage { canvas='playspace' mounted(){ this.indicatorPoint = new Point({x:200,y:200, radius: 100}) this.linePoint = new Point(100,100) this.targetPoint = this.indicatorPoint.project() this.dragging.addPoints(this.indicatorPoint, this.linePoint, this.targetPoint) let h = new Label(this.ctx, { fontSize: 50 , textAlign: "center" // , fontName: '"lexend deca"' }) // h.fillStyle = 'orange' h.position = new Point(300, 200) this.label = h; } updateText() { let a = this.indicatorPoint; // looks at targetPoint let b = this.linePoint; let rot = calculateAngle360(a, b, a.rotation) // let rot = invertClockRotation(calculateAngle180(a, b, a.rotation)) // let rot = calculateAngle180(a, b, a.rotation) // let rot = calculateInverseAngle180(a, b, a.rotation) this.label.text = rot.toFixed(0) } onMouseup(e) { this.linePoint.color = undefined } draw(ctx){ this.clear(ctx) let a = this.indicatorPoint; let b = this.linePoint; // a.rotation -= .1; a.pen.indicator(ctx) // a.pen.indicator(ctx) a.pen.line(ctx, b) a.lookAt(this.targetPoint) this.targetPoint.pen.fill(ctx, '#8822cc') b.pen.fill(ctx, '#99ddff') // this.linePoint.pen.indicator(ctx, {color: this.linePoint.color}) this.updateText() this.label.writeText(ctx) } } ;stage = MainStage.go();
Run
Meta Data
title Calculate Angles
imports ()
files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/setunset.js', '../point_src/stroke.js', '../point_src/point-content.js', '../point_src/pointlist.js', '../point_src/point.js', '../point_src/protractor.js', '../point_src/events.js', '../point_src/automouse.js', '../point_src/distances.js', '../point_src/dragging.js', '../point_src/functions/clamp.js', '../point_src/mirror.js', '../point_src/stage.js', '../point_src/text/label.js', '../point_src/text/alpha.js')
unused_keys ()
unknown_keys ('category',)
category ['angles']
filepath_exists True
path angle-point.js
filepath angle-point.js
clean_files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/setunset.js', '../point_src/stroke.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/relative-xy.js', '../point_src/pointcast.js', '../point_src/point.js', '../point_src/protractor.js', '../point_src/events.js', '../point_src/automouse.js', '../point_src/distances.js', '../point_src/text/beta.js', '../point_src/dragging.js', '../point_src/functions/clamp.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/text/alpha.js')
markdown {'html': '<p>This example presents a the angle value between two points (their rotation).</p>', 'content': '---\ntitle: Calculate Angles\ncategory: angles\nfiles:\n ../point_src/core/head.js\n ../point_src/pointpen.js\n ../point_src/pointdraw.js\n ../point_src/setunset.js\n ../point_src/stroke.js\n ../point_src/point-content.js\n ../point_src/pointlist.js\n ../point_src/point.js\n ../point_src/protractor.js\n ../point_src/events.js\n ../point_src/automouse.js\n ../point_src/distances.js\n ../point_src/dragging.js\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/text/alpha.js\n---\n\nThis example presents a the angle value between two points (their rotation).'}