-
Notifications
You must be signed in to change notification settings - Fork 18
/
copy-vertex.ts
61 lines (59 loc) · 1.62 KB
/
copy-vertex.ts
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
/*
* Copyright (C) 2019 Toshiba Corporation
* SPDX-License-Identifier: Apache-2.0
*/
import { Matrix } from "pixi.js";
import { EShapeLineOfAnyPointsPoint } from "./e-shape-line-of-any-points-point";
export const copyVertex = (
vertices: Float32Array,
internalTransform: Matrix,
voffset: number,
vcountPerPoint: number,
pointCount: number,
pointsValues: number[],
pointOffset: EShapeLineOfAnyPointsPoint
): void => {
const a = internalTransform.a;
const b = internalTransform.b;
const c = internalTransform.c;
const d = internalTransform.d;
let i = pointCount - 1;
let iv = voffset + i * vcountPerPoint;
if (pointOffset.isStaticX() && pointOffset.isStaticY()) {
const ox = pointOffset.getX(0);
const oy = pointOffset.getY(0);
for (; 0 <= i; --i) {
const ip = i << 1;
const px = pointsValues[ip] + ox;
const py = pointsValues[ip + 1] + oy;
const dx = a * px + c * py;
const dy = b * px + d * py;
let ivd = iv << 1;
let ivs = voffset << 1;
for (let j = 0; j < vcountPerPoint; ++j) {
vertices[ivd] = vertices[ivs] + dx;
vertices[ivd + 1] = vertices[ivs + 1] + dy;
ivd += 2;
ivs += 2;
}
iv -= vcountPerPoint;
}
} else {
for (; 0 <= i; --i) {
const ip = i << 1;
const px = pointsValues[ip] + pointOffset.getX(i);
const py = pointsValues[ip + 1] + pointOffset.getY(i);
const dx = a * px + c * py;
const dy = b * px + d * py;
let ivd = iv << 1;
let ivs = voffset << 1;
for (let j = 0; j < vcountPerPoint; ++j) {
vertices[ivd] = vertices[ivs] + dx;
vertices[ivd + 1] = vertices[ivs + 1] + dy;
ivd += 2;
ivs += 2;
}
iv -= vcountPerPoint;
}
}
};