Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3172x 3172x 3172x 3172x 3172x 1x 1x 81998x 81997x 81997x 2x 81997x 81995x 81995x 81997x 81997x 81997x 73832x 73832x 73832x 73832x 73832x 73832x 73832x 73832x 81998x 81998x 81998x 81998x 81998x 81998x 81998x 81998x 81998x 81998x 81998x 81998x 81998x 1x 1x 81991x 1x 1x 81994x 81994x 81994x 81994x 41643x 41643x 41643x 41643x 1x 1x 81991x 1x 1x 19x 1x 1x 15x 1x 1x 42486x 1x | /*----------------------------------------------------------------------+
| Title: LineElement.ts |
| A port of the software Geometry Applet by |
| Author: David E. Joyce |
| Department of Mathematics and Computer Science |
| Clark University |
| Worcester, MA 01610-1477 |
| U.S.A. |
| |
| http://aleph0.clarku.edu/~djoyce/home.html |
| djoyce@clarku.edu |
| |
| Date: February, 1996. Version 2.0.0 May, 1997. |
| TypeScript Port: 2019, Nelson Brown, brownnrl@gmail.com |
| https://www.nelsonbrown.net/ |
+----------------------------------------------------------------------*/
import {PointElement} from "../point/PointElement";
import {GeomElement} from "../GeomElement";
import {SlateCanvas} from "../../Slate";
interface ILineElementConstructor {
A : PointElement;
B : PointElement;
}
export class LineElement extends GeomElement {
protected _A : PointElement;
get A() : PointElement { return this._A; }
protected _B : PointElement;
get B() : PointElement { return this._B; }
constructor(ile?: ILineElementConstructor) {
super();
this.dimension = 1;
this._A = ile && ile.A || null;
this._B = ile && ile.B || null;
}
public drawEdge(c: HTMLCanvasElement, color?: string): void {
if (!this.visible && !this.shouldHighlight && this.emphasisAmount <= 0) return;
if (color == null) {
if (this.emphasized || this.shouldHighlight) {
color = this.edgeHighlightColor;
} else {
color = this.edgeColor;
}
}
if (color == null) return;
let ctx = c.getContext("2d");
ctx.strokeStyle = color;
// Stroke weight scales smoothly. Baseline is 1 (normal) or 3
// (slide-highlight); emphasisAmount interpolates up to 6 for
// full emphasis. emphasisAmount = 0 → baseline; 1 → 6 px;
// animator fades 1 → 0 over ~250 ms at the end of a transition
// so the post-animation settle isn't a hard pop.
const baseW = this.shouldHighlight ? 3 : 1;
ctx.lineWidth = (baseW + this.emphasisAmount * (6 - baseW)) * GeomElement.styleScale;
// Slide-transition animation: drawProgress < 1 traces only the
// first `progress` fraction of the line A → B. Default 1 keeps
// the full-line behaviour every existing consumer relies on.
let p = this.drawProgress;
let endX = this._A.x + (this._B.x - this._A.x) * p;
let endY = this._A.y + (this._B.y - this._A.y) * p;
ctx.beginPath();
ctx.moveTo(this._A.x, this._A.y);
ctx.lineTo(endX, endY);
ctx.stroke();
}
public drawFace(c: SlateCanvas): void {
}
public drawName(c: SlateCanvas): void {
if (!this.visible && !this.shouldHighlight && this.emphasisAmount <= 0) return;
if (this.nameColor == null || this.name == null) return;
if (this._A == null || !this._A.defined()) return;
if (this._B == null || !this._B.defined()) return;
const ix = Math.round((this._A.x + this._B.x) / 2);
const iy = Math.round((this._A.y + this._B.y) / 2);
this.drawString(ix, iy, c);
}
public drawVertex(c: SlateCanvas): void {
}
public rotate(pivot: PointElement, ac: number, as: number): void {
}
public translate(dx: number, dy: number): void {
}
public update(): void {
}
}
|