逐步完成前后端服务器

This commit is contained in:
2025-09-09 15:00:30 +08:00
parent fcb09432e9
commit c7dfa1e9fc
2937 changed files with 1477567 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import Path, { PathProps } from '../Path';
export declare class ArcShape {
cx: number;
cy: number;
r: number;
startAngle: number;
endAngle: number;
clockwise?: boolean;
}
export interface ArcProps extends PathProps {
shape?: Partial<ArcShape>;
}
declare class Arc extends Path<ArcProps> {
shape: ArcShape;
constructor(opts?: ArcProps);
getDefaultStyle(): {
stroke: string;
fill: string;
};
getDefaultShape(): ArcShape;
buildPath(ctx: CanvasRenderingContext2D, shape: ArcShape): void;
}
export default Arc;

44
frontend/node_modules/zrender/lib/graphic/shape/Arc.js generated vendored Normal file
View File

@ -0,0 +1,44 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var ArcShape = (function () {
function ArcShape() {
this.cx = 0;
this.cy = 0;
this.r = 0;
this.startAngle = 0;
this.endAngle = Math.PI * 2;
this.clockwise = true;
}
return ArcShape;
}());
export { ArcShape };
var Arc = (function (_super) {
__extends(Arc, _super);
function Arc(opts) {
return _super.call(this, opts) || this;
}
Arc.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
Arc.prototype.getDefaultShape = function () {
return new ArcShape();
};
Arc.prototype.buildPath = function (ctx, shape) {
var x = shape.cx;
var y = shape.cy;
var r = Math.max(shape.r, 0);
var startAngle = shape.startAngle;
var endAngle = shape.endAngle;
var clockwise = shape.clockwise;
var unitX = Math.cos(startAngle);
var unitY = Math.sin(startAngle);
ctx.moveTo(unitX * r + x, unitY * r + y);
ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
};
return Arc;
}(Path));
Arc.prototype.type = 'arc';
export default Arc;

View File

@ -0,0 +1,28 @@
import Path, { PathProps } from '../Path';
export declare class BezierCurveShape {
x1: number;
y1: number;
x2: number;
y2: number;
cpx1: number;
cpy1: number;
cpx2?: number;
cpy2?: number;
percent: number;
}
export interface BezierCurveProps extends PathProps {
shape?: Partial<BezierCurveShape>;
}
declare class BezierCurve extends Path<BezierCurveProps> {
shape: BezierCurveShape;
constructor(opts?: BezierCurveProps);
getDefaultStyle(): {
stroke: string;
fill: string;
};
getDefaultShape(): BezierCurveShape;
buildPath(ctx: CanvasRenderingContext2D, shape: BezierCurveShape): void;
pointAt(t: number): number[];
tangentAt(t: number): number[];
}
export default BezierCurve;

View File

@ -0,0 +1,99 @@
import { __extends } from "tslib";
import Path from '../Path.js';
import * as vec2 from '../../core/vector.js';
import { quadraticSubdivide, cubicSubdivide, quadraticAt, cubicAt, quadraticDerivativeAt, cubicDerivativeAt } from '../../core/curve.js';
var out = [];
var BezierCurveShape = (function () {
function BezierCurveShape() {
this.x1 = 0;
this.y1 = 0;
this.x2 = 0;
this.y2 = 0;
this.cpx1 = 0;
this.cpy1 = 0;
this.percent = 1;
}
return BezierCurveShape;
}());
export { BezierCurveShape };
function someVectorAt(shape, t, isTangent) {
var cpx2 = shape.cpx2;
var cpy2 = shape.cpy2;
if (cpx2 != null || cpy2 != null) {
return [
(isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t),
(isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)
];
}
else {
return [
(isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t),
(isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)
];
}
}
var BezierCurve = (function (_super) {
__extends(BezierCurve, _super);
function BezierCurve(opts) {
return _super.call(this, opts) || this;
}
BezierCurve.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
BezierCurve.prototype.getDefaultShape = function () {
return new BezierCurveShape();
};
BezierCurve.prototype.buildPath = function (ctx, shape) {
var x1 = shape.x1;
var y1 = shape.y1;
var x2 = shape.x2;
var y2 = shape.y2;
var cpx1 = shape.cpx1;
var cpy1 = shape.cpy1;
var cpx2 = shape.cpx2;
var cpy2 = shape.cpy2;
var percent = shape.percent;
if (percent === 0) {
return;
}
ctx.moveTo(x1, y1);
if (cpx2 == null || cpy2 == null) {
if (percent < 1) {
quadraticSubdivide(x1, cpx1, x2, percent, out);
cpx1 = out[1];
x2 = out[2];
quadraticSubdivide(y1, cpy1, y2, percent, out);
cpy1 = out[1];
y2 = out[2];
}
ctx.quadraticCurveTo(cpx1, cpy1, x2, y2);
}
else {
if (percent < 1) {
cubicSubdivide(x1, cpx1, cpx2, x2, percent, out);
cpx1 = out[1];
cpx2 = out[2];
x2 = out[3];
cubicSubdivide(y1, cpy1, cpy2, y2, percent, out);
cpy1 = out[1];
cpy2 = out[2];
y2 = out[3];
}
ctx.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x2, y2);
}
};
BezierCurve.prototype.pointAt = function (t) {
return someVectorAt(this.shape, t, false);
};
BezierCurve.prototype.tangentAt = function (t) {
var p = someVectorAt(this.shape, t, true);
return vec2.normalize(p, p);
};
return BezierCurve;
}(Path));
;
BezierCurve.prototype.type = 'bezier-curve';
export default BezierCurve;

View File

@ -0,0 +1,16 @@
import Path, { PathProps } from '../Path';
export declare class CircleShape {
cx: number;
cy: number;
r: number;
}
export interface CircleProps extends PathProps {
shape?: Partial<CircleShape>;
}
declare class Circle extends Path<CircleProps> {
shape: CircleShape;
constructor(opts?: CircleProps);
getDefaultShape(): CircleShape;
buildPath(ctx: CanvasRenderingContext2D, shape: CircleShape): void;
}
export default Circle;

View File

@ -0,0 +1,28 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var CircleShape = (function () {
function CircleShape() {
this.cx = 0;
this.cy = 0;
this.r = 0;
}
return CircleShape;
}());
export { CircleShape };
var Circle = (function (_super) {
__extends(Circle, _super);
function Circle(opts) {
return _super.call(this, opts) || this;
}
Circle.prototype.getDefaultShape = function () {
return new CircleShape();
};
Circle.prototype.buildPath = function (ctx, shape) {
ctx.moveTo(shape.cx + shape.r, shape.cy);
ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2);
};
return Circle;
}(Path));
;
Circle.prototype.type = 'circle';
export default Circle;

View File

@ -0,0 +1,17 @@
import Path, { PathProps } from '../Path';
export declare class DropletShape {
cx: number;
cy: number;
width: number;
height: number;
}
export interface DropletProps extends PathProps {
shape?: Partial<DropletShape>;
}
declare class Droplet extends Path<DropletProps> {
shape: DropletShape;
constructor(opts?: DropletProps);
getDefaultShape(): DropletShape;
buildPath(ctx: CanvasRenderingContext2D, shape: DropletShape): void;
}
export default Droplet;

View File

@ -0,0 +1,34 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var DropletShape = (function () {
function DropletShape() {
this.cx = 0;
this.cy = 0;
this.width = 0;
this.height = 0;
}
return DropletShape;
}());
export { DropletShape };
var Droplet = (function (_super) {
__extends(Droplet, _super);
function Droplet(opts) {
return _super.call(this, opts) || this;
}
Droplet.prototype.getDefaultShape = function () {
return new DropletShape();
};
Droplet.prototype.buildPath = function (ctx, shape) {
var x = shape.cx;
var y = shape.cy;
var a = shape.width;
var b = shape.height;
ctx.moveTo(x, y + a);
ctx.bezierCurveTo(x + a, y + a, x + a * 3 / 2, y - a / 3, x, y - b);
ctx.bezierCurveTo(x - a * 3 / 2, y - a / 3, x - a, y + a, x, y + a);
ctx.closePath();
};
return Droplet;
}(Path));
Droplet.prototype.type = 'droplet';
export default Droplet;

View File

@ -0,0 +1,17 @@
import Path, { PathProps } from '../Path';
export declare class EllipseShape {
cx: number;
cy: number;
rx: number;
ry: number;
}
export interface EllipseProps extends PathProps {
shape?: Partial<EllipseShape>;
}
declare class Ellipse extends Path<EllipseProps> {
shape: EllipseShape;
constructor(opts?: EllipseProps);
getDefaultShape(): EllipseShape;
buildPath(ctx: CanvasRenderingContext2D, shape: EllipseShape): void;
}
export default Ellipse;

View File

@ -0,0 +1,39 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var EllipseShape = (function () {
function EllipseShape() {
this.cx = 0;
this.cy = 0;
this.rx = 0;
this.ry = 0;
}
return EllipseShape;
}());
export { EllipseShape };
var Ellipse = (function (_super) {
__extends(Ellipse, _super);
function Ellipse(opts) {
return _super.call(this, opts) || this;
}
Ellipse.prototype.getDefaultShape = function () {
return new EllipseShape();
};
Ellipse.prototype.buildPath = function (ctx, shape) {
var k = 0.5522848;
var x = shape.cx;
var y = shape.cy;
var a = shape.rx;
var b = shape.ry;
var ox = a * k;
var oy = b * k;
ctx.moveTo(x - a, y);
ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b);
ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y);
ctx.bezierCurveTo(x + a, y + oy, x + ox, y + b, x, y + b);
ctx.bezierCurveTo(x - ox, y + b, x - a, y + oy, x - a, y);
ctx.closePath();
};
return Ellipse;
}(Path));
Ellipse.prototype.type = 'ellipse';
export default Ellipse;

View File

@ -0,0 +1,17 @@
import Path, { PathProps } from '../Path';
export declare class HeartShape {
cx: number;
cy: number;
width: number;
height: number;
}
export interface HeartProps extends PathProps {
shape?: Partial<HeartShape>;
}
declare class Heart extends Path<HeartProps> {
shape: HeartShape;
constructor(opts?: HeartProps);
getDefaultShape(): HeartShape;
buildPath(ctx: CanvasRenderingContext2D, shape: HeartShape): void;
}
export default Heart;

View File

@ -0,0 +1,33 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var HeartShape = (function () {
function HeartShape() {
this.cx = 0;
this.cy = 0;
this.width = 0;
this.height = 0;
}
return HeartShape;
}());
export { HeartShape };
var Heart = (function (_super) {
__extends(Heart, _super);
function Heart(opts) {
return _super.call(this, opts) || this;
}
Heart.prototype.getDefaultShape = function () {
return new HeartShape();
};
Heart.prototype.buildPath = function (ctx, shape) {
var x = shape.cx;
var y = shape.cy;
var a = shape.width;
var b = shape.height;
ctx.moveTo(x, y);
ctx.bezierCurveTo(x + a / 2, y - b * 2 / 3, x + a * 2, y + b / 3, x, y + b);
ctx.bezierCurveTo(x - a * 2, y + b / 3, x - a / 2, y - b * 2 / 3, x, y);
};
return Heart;
}(Path));
Heart.prototype.type = 'heart';
export default Heart;

View File

@ -0,0 +1,17 @@
import Path, { PathProps } from '../Path';
export declare class IsogonShape {
x: number;
y: number;
r: number;
n: number;
}
export interface IsogonProps extends PathProps {
shape?: Partial<IsogonShape>;
}
declare class Isogon extends Path<IsogonProps> {
shape: IsogonShape;
constructor(opts?: IsogonProps);
getDefaultShape(): IsogonShape;
buildPath(ctx: CanvasRenderingContext2D, shape: IsogonShape): void;
}
export default Isogon;

View File

@ -0,0 +1,45 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var PI = Math.PI;
var sin = Math.sin;
var cos = Math.cos;
var IsogonShape = (function () {
function IsogonShape() {
this.x = 0;
this.y = 0;
this.r = 0;
this.n = 0;
}
return IsogonShape;
}());
export { IsogonShape };
var Isogon = (function (_super) {
__extends(Isogon, _super);
function Isogon(opts) {
return _super.call(this, opts) || this;
}
Isogon.prototype.getDefaultShape = function () {
return new IsogonShape();
};
Isogon.prototype.buildPath = function (ctx, shape) {
var n = shape.n;
if (!n || n < 2) {
return;
}
var x = shape.x;
var y = shape.y;
var r = shape.r;
var dStep = 2 * PI / n;
var deg = -PI / 2;
ctx.moveTo(x + r * cos(deg), y + r * sin(deg));
for (var i = 0, end = n - 1; i < end; i++) {
deg += dStep;
ctx.lineTo(x + r * cos(deg), y + r * sin(deg));
}
ctx.closePath();
return;
};
return Isogon;
}(Path));
Isogon.prototype.type = 'isogon';
export default Isogon;

View File

@ -0,0 +1,24 @@
import Path, { PathProps } from '../Path';
import { VectorArray } from '../../core/vector';
export declare class LineShape {
x1: number;
y1: number;
x2: number;
y2: number;
percent: number;
}
export interface LineProps extends PathProps {
shape?: Partial<LineShape>;
}
declare class Line extends Path<LineProps> {
shape: LineShape;
constructor(opts?: LineProps);
getDefaultStyle(): {
stroke: string;
fill: string;
};
getDefaultShape(): LineShape;
buildPath(ctx: CanvasRenderingContext2D, shape: LineShape): void;
pointAt(p: number): VectorArray;
}
export default Line;

View File

@ -0,0 +1,69 @@
import { __extends } from "tslib";
import Path from '../Path.js';
import { subPixelOptimizeLine } from '../helper/subPixelOptimize.js';
var subPixelOptimizeOutputShape = {};
var LineShape = (function () {
function LineShape() {
this.x1 = 0;
this.y1 = 0;
this.x2 = 0;
this.y2 = 0;
this.percent = 1;
}
return LineShape;
}());
export { LineShape };
var Line = (function (_super) {
__extends(Line, _super);
function Line(opts) {
return _super.call(this, opts) || this;
}
Line.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
Line.prototype.getDefaultShape = function () {
return new LineShape();
};
Line.prototype.buildPath = function (ctx, shape) {
var x1;
var y1;
var x2;
var y2;
if (this.subPixelOptimize) {
var optimizedShape = subPixelOptimizeLine(subPixelOptimizeOutputShape, shape, this.style);
x1 = optimizedShape.x1;
y1 = optimizedShape.y1;
x2 = optimizedShape.x2;
y2 = optimizedShape.y2;
}
else {
x1 = shape.x1;
y1 = shape.y1;
x2 = shape.x2;
y2 = shape.y2;
}
var percent = shape.percent;
if (percent === 0) {
return;
}
ctx.moveTo(x1, y1);
if (percent < 1) {
x2 = x1 * (1 - percent) + x2 * percent;
y2 = y1 * (1 - percent) + y2 * percent;
}
ctx.lineTo(x2, y2);
};
Line.prototype.pointAt = function (p) {
var shape = this.shape;
return [
shape.x1 * (1 - p) + shape.x2 * p,
shape.y1 * (1 - p) + shape.y2 * p
];
};
return Line;
}(Path));
Line.prototype.type = 'line';
export default Line;

View File

@ -0,0 +1,17 @@
import Path, { PathProps } from '../Path';
import { VectorArray } from '../../core/vector';
export declare class PolygonShape {
points: VectorArray[];
smooth?: number;
smoothConstraint?: VectorArray[];
}
export interface PolygonProps extends PathProps {
shape?: Partial<PolygonShape>;
}
declare class Polygon extends Path<PolygonProps> {
shape: PolygonShape;
constructor(opts?: PolygonProps);
getDefaultShape(): PolygonShape;
buildPath(ctx: CanvasRenderingContext2D, shape: PolygonShape): void;
}
export default Polygon;

View File

@ -0,0 +1,28 @@
import { __extends } from "tslib";
import Path from '../Path.js';
import * as polyHelper from '../helper/poly.js';
var PolygonShape = (function () {
function PolygonShape() {
this.points = null;
this.smooth = 0;
this.smoothConstraint = null;
}
return PolygonShape;
}());
export { PolygonShape };
var Polygon = (function (_super) {
__extends(Polygon, _super);
function Polygon(opts) {
return _super.call(this, opts) || this;
}
Polygon.prototype.getDefaultShape = function () {
return new PolygonShape();
};
Polygon.prototype.buildPath = function (ctx, shape) {
polyHelper.buildPath(ctx, shape, true);
};
return Polygon;
}(Path));
;
Polygon.prototype.type = 'polygon';
export default Polygon;

View File

@ -0,0 +1,22 @@
import Path, { PathProps } from '../Path';
import { VectorArray } from '../../core/vector';
export declare class PolylineShape {
points: VectorArray[];
percent?: number;
smooth?: number;
smoothConstraint?: VectorArray[];
}
export interface PolylineProps extends PathProps {
shape?: Partial<PolylineShape>;
}
declare class Polyline extends Path<PolylineProps> {
shape: PolylineShape;
constructor(opts?: PolylineProps);
getDefaultStyle(): {
stroke: string;
fill: string;
};
getDefaultShape(): PolylineShape;
buildPath(ctx: CanvasRenderingContext2D, shape: PolylineShape): void;
}
export default Polyline;

View File

@ -0,0 +1,34 @@
import { __extends } from "tslib";
import Path from '../Path.js';
import * as polyHelper from '../helper/poly.js';
var PolylineShape = (function () {
function PolylineShape() {
this.points = null;
this.percent = 1;
this.smooth = 0;
this.smoothConstraint = null;
}
return PolylineShape;
}());
export { PolylineShape };
var Polyline = (function (_super) {
__extends(Polyline, _super);
function Polyline(opts) {
return _super.call(this, opts) || this;
}
Polyline.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
Polyline.prototype.getDefaultShape = function () {
return new PolylineShape();
};
Polyline.prototype.buildPath = function (ctx, shape) {
polyHelper.buildPath(ctx, shape, false);
};
return Polyline;
}(Path));
Polyline.prototype.type = 'polyline';
export default Polyline;

View File

@ -0,0 +1,19 @@
import Path, { PathProps } from '../Path';
export declare class RectShape {
r?: number | number[];
x: number;
y: number;
width: number;
height: number;
}
export interface RectProps extends PathProps {
shape?: Partial<RectShape>;
}
declare class Rect extends Path<RectProps> {
shape: RectShape;
constructor(opts?: RectProps);
getDefaultShape(): RectShape;
buildPath(ctx: CanvasRenderingContext2D, shape: RectShape): void;
isZeroArea(): boolean;
}
export default Rect;

View File

@ -0,0 +1,57 @@
import { __extends } from "tslib";
import Path from '../Path.js';
import * as roundRectHelper from '../helper/roundRect.js';
import { subPixelOptimizeRect } from '../helper/subPixelOptimize.js';
var RectShape = (function () {
function RectShape() {
this.x = 0;
this.y = 0;
this.width = 0;
this.height = 0;
}
return RectShape;
}());
export { RectShape };
var subPixelOptimizeOutputShape = {};
var Rect = (function (_super) {
__extends(Rect, _super);
function Rect(opts) {
return _super.call(this, opts) || this;
}
Rect.prototype.getDefaultShape = function () {
return new RectShape();
};
Rect.prototype.buildPath = function (ctx, shape) {
var x;
var y;
var width;
var height;
if (this.subPixelOptimize) {
var optimizedShape = subPixelOptimizeRect(subPixelOptimizeOutputShape, shape, this.style);
x = optimizedShape.x;
y = optimizedShape.y;
width = optimizedShape.width;
height = optimizedShape.height;
optimizedShape.r = shape.r;
shape = optimizedShape;
}
else {
x = shape.x;
y = shape.y;
width = shape.width;
height = shape.height;
}
if (!shape.r) {
ctx.rect(x, y, width, height);
}
else {
roundRectHelper.buildPath(ctx, shape);
}
};
Rect.prototype.isZeroArea = function () {
return !this.shape.width || !this.shape.height;
};
return Rect;
}(Path));
Rect.prototype.type = 'rect';
export default Rect;

View File

@ -0,0 +1,17 @@
import Path, { PathProps } from '../Path';
export declare class RingShape {
cx: number;
cy: number;
r: number;
r0: number;
}
export interface RingProps extends PathProps {
shape?: Partial<RingShape>;
}
declare class Ring extends Path<RingProps> {
shape: RingShape;
constructor(opts?: RingProps);
getDefaultShape(): RingShape;
buildPath(ctx: CanvasRenderingContext2D, shape: RingShape): void;
}
export default Ring;

View File

@ -0,0 +1,33 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var RingShape = (function () {
function RingShape() {
this.cx = 0;
this.cy = 0;
this.r = 0;
this.r0 = 0;
}
return RingShape;
}());
export { RingShape };
var Ring = (function (_super) {
__extends(Ring, _super);
function Ring(opts) {
return _super.call(this, opts) || this;
}
Ring.prototype.getDefaultShape = function () {
return new RingShape();
};
Ring.prototype.buildPath = function (ctx, shape) {
var x = shape.cx;
var y = shape.cy;
var PI2 = Math.PI * 2;
ctx.moveTo(x + shape.r, y);
ctx.arc(x, y, shape.r, 0, PI2, false);
ctx.moveTo(x + shape.r0, y);
ctx.arc(x, y, shape.r0, 0, PI2, true);
};
return Ring;
}(Path));
Ring.prototype.type = 'ring';
export default Ring;

View File

@ -0,0 +1,22 @@
import Path, { PathProps } from '../Path';
export declare class RoseShape {
cx: number;
cy: number;
r: number[];
k: number;
n: number;
}
export interface RoseProps extends PathProps {
shape?: Partial<RoseShape>;
}
declare class Rose extends Path<RoseProps> {
shape: RoseShape;
constructor(opts?: RoseProps);
getDefaultStyle(): {
stroke: string;
fill: string;
};
getDefaultShape(): RoseShape;
buildPath(ctx: CanvasRenderingContext2D, shape: RoseShape): void;
}
export default Rose;

View File

@ -0,0 +1,59 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var sin = Math.sin;
var cos = Math.cos;
var radian = Math.PI / 180;
var RoseShape = (function () {
function RoseShape() {
this.cx = 0;
this.cy = 0;
this.r = [];
this.k = 0;
this.n = 1;
}
return RoseShape;
}());
export { RoseShape };
var Rose = (function (_super) {
__extends(Rose, _super);
function Rose(opts) {
return _super.call(this, opts) || this;
}
Rose.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
Rose.prototype.getDefaultShape = function () {
return new RoseShape();
};
Rose.prototype.buildPath = function (ctx, shape) {
var R = shape.r;
var k = shape.k;
var n = shape.n;
var x0 = shape.cx;
var y0 = shape.cy;
var x;
var y;
var r;
ctx.moveTo(x0, y0);
for (var i = 0, len = R.length; i < len; i++) {
r = R[i];
for (var j = 0; j <= 360 * n; j++) {
x = r
* sin(k / n * j % 360 * radian)
* cos(j * radian)
+ x0;
y = r
* sin(k / n * j % 360 * radian)
* sin(j * radian)
+ y0;
ctx.lineTo(x, y);
}
}
};
return Rose;
}(Path));
Rose.prototype.type = 'rose';
export default Rose;

View File

@ -0,0 +1,22 @@
import Path, { PathProps } from '../Path';
export declare class SectorShape {
cx: number;
cy: number;
r0: number;
r: number;
startAngle: number;
endAngle: number;
clockwise: boolean;
cornerRadius: number | number[];
}
export interface SectorProps extends PathProps {
shape?: Partial<SectorShape>;
}
declare class Sector extends Path<SectorProps> {
shape: SectorShape;
constructor(opts?: SectorProps);
getDefaultShape(): SectorShape;
buildPath(ctx: CanvasRenderingContext2D, shape: SectorShape): void;
isZeroArea(): boolean;
}
export default Sector;

View File

@ -0,0 +1,36 @@
import { __extends } from "tslib";
import Path from '../Path.js';
import * as roundSectorHelper from '../helper/roundSector.js';
var SectorShape = (function () {
function SectorShape() {
this.cx = 0;
this.cy = 0;
this.r0 = 0;
this.r = 0;
this.startAngle = 0;
this.endAngle = Math.PI * 2;
this.clockwise = true;
this.cornerRadius = 0;
}
return SectorShape;
}());
export { SectorShape };
var Sector = (function (_super) {
__extends(Sector, _super);
function Sector(opts) {
return _super.call(this, opts) || this;
}
Sector.prototype.getDefaultShape = function () {
return new SectorShape();
};
Sector.prototype.buildPath = function (ctx, shape) {
roundSectorHelper.buildPath(ctx, shape);
};
Sector.prototype.isZeroArea = function () {
return this.shape.startAngle === this.shape.endAngle
|| this.shape.r === this.shape.r0;
};
return Sector;
}(Path));
Sector.prototype.type = 'sector';
export default Sector;

View File

@ -0,0 +1,18 @@
import Path, { PathProps } from '../Path';
export declare class StarShape {
cx: number;
cy: number;
n: number;
r0: number;
r: number;
}
export interface StarProps extends PathProps {
shape?: Partial<StarShape>;
}
declare class Star extends Path<StarProps> {
shape: StarShape;
constructor(opts?: StarProps);
getDefaultShape(): StarShape;
buildPath(ctx: CanvasRenderingContext2D, shape: StarShape): void;
}
export default Star;

View File

@ -0,0 +1,54 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var PI = Math.PI;
var cos = Math.cos;
var sin = Math.sin;
var StarShape = (function () {
function StarShape() {
this.cx = 0;
this.cy = 0;
this.n = 3;
this.r = 0;
}
return StarShape;
}());
export { StarShape };
var Star = (function (_super) {
__extends(Star, _super);
function Star(opts) {
return _super.call(this, opts) || this;
}
Star.prototype.getDefaultShape = function () {
return new StarShape();
};
Star.prototype.buildPath = function (ctx, shape) {
var n = shape.n;
if (!n || n < 2) {
return;
}
var x = shape.cx;
var y = shape.cy;
var r = shape.r;
var r0 = shape.r0;
if (r0 == null) {
r0 = n > 4
? r * cos(2 * PI / n) / cos(PI / n)
: r / 3;
}
var dStep = PI / n;
var deg = -PI / 2;
var xStart = x + r * cos(deg);
var yStart = y + r * sin(deg);
deg += dStep;
ctx.moveTo(xStart, yStart);
for (var i = 0, end = n * 2 - 1, ri = void 0; i < end; i++) {
ri = i % 2 === 0 ? r0 : r;
ctx.lineTo(x + ri * cos(deg), y + ri * sin(deg));
deg += dStep;
}
ctx.closePath();
};
return Star;
}(Path));
Star.prototype.type = 'star';
export default Star;

View File

@ -0,0 +1,23 @@
import Path, { PathProps } from '../Path';
export declare class TrochoidShape {
cx: number;
cy: number;
r: number;
r0: number;
d: number;
location: string;
}
export interface TrochoidProps extends PathProps {
shape?: Partial<TrochoidShape>;
}
declare class Trochoid extends Path<TrochoidProps> {
shape: TrochoidShape;
constructor(opts?: TrochoidProps);
getDefaultStyle(): {
stroke: string;
fill: string;
};
getDefaultShape(): TrochoidShape;
buildPath(ctx: CanvasRenderingContext2D, shape: TrochoidShape): void;
}
export default Trochoid;

View File

@ -0,0 +1,71 @@
import { __extends } from "tslib";
import Path from '../Path.js';
var cos = Math.cos;
var sin = Math.sin;
var TrochoidShape = (function () {
function TrochoidShape() {
this.cx = 0;
this.cy = 0;
this.r = 0;
this.r0 = 0;
this.d = 0;
this.location = 'out';
}
return TrochoidShape;
}());
export { TrochoidShape };
var Trochoid = (function (_super) {
__extends(Trochoid, _super);
function Trochoid(opts) {
return _super.call(this, opts) || this;
}
Trochoid.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
Trochoid.prototype.getDefaultShape = function () {
return new TrochoidShape();
};
Trochoid.prototype.buildPath = function (ctx, shape) {
var R = shape.r;
var r = shape.r0;
var d = shape.d;
var offsetX = shape.cx;
var offsetY = shape.cy;
var delta = shape.location === 'out' ? 1 : -1;
var x1;
var y1;
var x2;
var y2;
if (shape.location && R <= r) {
return;
}
var num = 0;
var i = 1;
var theta;
x1 = (R + delta * r) * cos(0)
- delta * d * cos(0) + offsetX;
y1 = (R + delta * r) * sin(0)
- d * sin(0) + offsetY;
ctx.moveTo(x1, y1);
do {
num++;
} while ((r * num) % (R + delta * r) !== 0);
do {
theta = Math.PI / 180 * i;
x2 = (R + delta * r) * cos(theta)
- delta * d * cos((R / r + delta) * theta)
+ offsetX;
y2 = (R + delta * r) * sin(theta)
- d * sin((R / r + delta) * theta)
+ offsetY;
ctx.lineTo(x2, y2);
i++;
} while (i <= (r * num) / (R + delta * r) * 360);
};
return Trochoid;
}(Path));
Trochoid.prototype.type = 'trochoid';
export default Trochoid;