make arrow with tension a bit better

This commit is contained in:
Anton Lavrenov
2019-08-07 11:42:35 +07:00
parent ffe8456496
commit 85d1cdd09c
5 changed files with 86 additions and 1344 deletions

View File

@@ -53,8 +53,8 @@ export class Arrow extends Line<ArrowConfig> {
var dx, dy;
if (fromTension) {
dx = points[n - 2] - tp[n - 2];
dy = points[n - 1] - tp[n - 1];
dx = points[n - 2] - (tp[tp.length - 2] + tp[tp.length - 4]) / 2;
dy = points[n - 1] - (tp[tp.length - 1] + tp[tp.length - 3]) / 2;
} else {
dx = points[n - 2] - points[n - 4];
dy = points[n - 1] - points[n - 3];
@@ -78,8 +78,8 @@ export class Arrow extends Line<ArrowConfig> {
ctx.save();
ctx.translate(points[0], points[1]);
if (fromTension) {
dx = tp[0] - points[0];
dy = tp[1] - points[1];
dx = (tp[0] + tp[2]) / 2 - points[0];
dy = (tp[1] + tp[3]) / 2 - points[1];
} else {
dx = points[2] - points[0];
dy = points[3] - points[1];

View File

@@ -5,6 +5,7 @@ import { getNumberValidator, getNumberArrayValidator } from '../Validators';
import { _registerNode } from '../Global';
import { GetSet } from '../types';
import { Context } from '../Context';
export interface LineConfig extends ShapeConfig {
points: number[];
@@ -50,7 +51,7 @@ export class Line<Config extends LineConfig = LineConfig> extends Shape<
);
}
_sceneFunc(context) {
_sceneFunc(context: Context) {
var points = this.points(),
length = points.length,
tension = this.tension(),