123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import { Line } from '../line';
- import { LineTo } from './lineto';
- import { Segment } from './segment';
- export class Close extends Segment {
- get end() {
- if (!this.subpathStartSegment) {
- throw new Error('Missing subpath start segment. (This segment needs a subpath ' +
- 'start segment (e.g. MoveTo), or segment has not yet been added' +
- ' to a path.)');
- }
- return this.subpathStartSegment.end;
- }
- get type() {
- return 'Z';
- }
- get line() {
- return new Line(this.start, this.end);
- }
- bbox() {
- return this.line.bbox();
- }
- closestPoint(p) {
- return this.line.closestPoint(p);
- }
- closestPointLength(p) {
- return this.line.closestPointLength(p);
- }
- closestPointNormalizedLength(p) {
- return this.line.closestPointNormalizedLength(p);
- }
- closestPointTangent(p) {
- return this.line.closestPointTangent(p);
- }
- length() {
- return this.line.length();
- }
- divideAt(ratio) {
- const divided = this.line.divideAt(ratio);
- return [
- // do not actually cut into the segment, first divided part can stay as Z
- divided[1].isDifferentiable() ? new LineTo(divided[0]) : this.clone(),
- new LineTo(divided[1]),
- ];
- }
- divideAtLength(length) {
- const divided = this.line.divideAtLength(length);
- return [
- divided[1].isDifferentiable() ? new LineTo(divided[0]) : this.clone(),
- new LineTo(divided[1]),
- ];
- }
- getSubdivisions() {
- return [];
- }
- pointAt(ratio) {
- return this.line.pointAt(ratio);
- }
- pointAtLength(length) {
- return this.line.pointAtLength(length);
- }
- tangentAt(ratio) {
- return this.line.tangentAt(ratio);
- }
- tangentAtLength(length) {
- return this.line.tangentAtLength(length);
- }
- isDifferentiable() {
- if (!this.previousSegment || !this.subpathStartSegment) {
- return false;
- }
- return !this.start.equals(this.end);
- }
- scale() {
- return this;
- }
- rotate() {
- return this;
- }
- translate() {
- return this;
- }
- equals(s) {
- return (this.type === s.type &&
- this.start.equals(s.start) &&
- this.end.equals(s.end));
- }
- clone() {
- return new Close();
- }
- toJSON() {
- return {
- type: this.type,
- start: this.start.toJSON(),
- end: this.end.toJSON(),
- };
- }
- serialize() {
- return this.type;
- }
- }
- (function (Close) {
- function create() {
- return new Close();
- }
- Close.create = create;
- })(Close || (Close = {}));
- //# sourceMappingURL=close.js.map
|