@next2d/webgl 3.19.1 → 3.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/Context/usecase/ContextBitmapStrokeUseCase.js +6 -8
- package/src/Context/usecase/ContextGradientStrokeUseCase.js +6 -8
- package/src/Context/usecase/ContextStrokeUseCase.js +6 -8
- package/src/Mesh/usecase/MeshStrokeCurrentPathUseCase.d.ts +13 -0
- package/src/Mesh/usecase/MeshStrokeCurrentPathUseCase.js +46 -0
- package/src/NativeShape.d.ts +9 -0
- package/src/NativeShape.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/webgl",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"description": "Next2D Webgl Package",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@next2d/texture-packer": "3.
|
|
28
|
-
"@next2d/render-queue": "3.
|
|
27
|
+
"@next2d/texture-packer": "3.20.0",
|
|
28
|
+
"@next2d/render-queue": "3.20.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { execute as meshStrokeGenerateUseCase } from "../../Mesh/usecase/MeshStrokeGenerateUseCase";
|
|
1
|
+
import { execute as meshStrokeCurrentPathUseCase } from "../../Mesh/usecase/MeshStrokeCurrentPathUseCase";
|
|
3
2
|
import { $bitmapData } from "../../Bitmap";
|
|
4
|
-
import { $
|
|
3
|
+
import { $fillTypes, $fillBufferIndexes } from "../../Mesh";
|
|
5
4
|
/**
|
|
6
5
|
* @description パスコマンドの線のビットマップの描画を実行します。
|
|
7
6
|
* Execute drawing of bitmap of line of path command.
|
|
@@ -17,15 +16,14 @@ import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
|
|
|
17
16
|
* @protected
|
|
18
17
|
*/
|
|
19
18
|
export const execute = (pixels, matrix, width, height, repeat, smooth) => {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// いまの経路を線のメッシュにして、塗りのバッファへ追加する
|
|
20
|
+
const indexCount = meshStrokeCurrentPathUseCase();
|
|
21
|
+
if (indexCount < 0) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
// 塗りの種類を追加
|
|
25
25
|
$fillTypes.push("bitmap");
|
|
26
|
-
const mesh = meshStrokeGenerateUseCase(vertices);
|
|
27
|
-
$addFillBuffer(mesh.buffer);
|
|
28
26
|
// 塗りのインデックスを追加
|
|
29
|
-
$fillBufferIndexes.push(
|
|
27
|
+
$fillBufferIndexes.push(indexCount);
|
|
30
28
|
$bitmapData.push(pixels, matrix, width, height, repeat, smooth);
|
|
31
29
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { execute as meshStrokeGenerateUseCase } from "../../Mesh/usecase/MeshStrokeGenerateUseCase";
|
|
1
|
+
import { execute as meshStrokeCurrentPathUseCase } from "../../Mesh/usecase/MeshStrokeCurrentPathUseCase";
|
|
3
2
|
import { $gradientData } from "../../Gradient";
|
|
4
|
-
import { $
|
|
3
|
+
import { $fillTypes, $fillBufferIndexes } from "../../Mesh";
|
|
5
4
|
/**
|
|
6
5
|
* @description 線のグラデーションを実行
|
|
7
6
|
* Execute gradient of line
|
|
@@ -17,16 +16,15 @@ import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
|
|
|
17
16
|
* @protected
|
|
18
17
|
*/
|
|
19
18
|
export const execute = (type, stops, matrix, spread, interpolation, focal) => {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// いまの経路を線のメッシュにして、塗りのバッファへ追加する
|
|
20
|
+
const indexCount = meshStrokeCurrentPathUseCase();
|
|
21
|
+
if (indexCount < 0) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
// 塗りの種類を追加
|
|
25
25
|
$fillTypes.push(type === 0 ? "linear" : "radial");
|
|
26
|
-
const mesh = meshStrokeGenerateUseCase(vertices);
|
|
27
|
-
$addFillBuffer(mesh.buffer);
|
|
28
26
|
// 塗りのインデックスを追加
|
|
29
|
-
$fillBufferIndexes.push(
|
|
27
|
+
$fillBufferIndexes.push(indexCount);
|
|
30
28
|
$gradientData.push(stops, matrix, spread, interpolation);
|
|
31
29
|
if (type === 1) {
|
|
32
30
|
$gradientData.push(focal);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
|
|
1
|
+
import { execute as meshStrokeCurrentPathUseCase } from "../../Mesh/usecase/MeshStrokeCurrentPathUseCase";
|
|
2
|
+
import { $fillTypes, $fillBufferIndexes } from "../../Mesh";
|
|
4
3
|
/**
|
|
5
4
|
* @description ストロークを描画
|
|
6
5
|
* Draw a stroke
|
|
@@ -10,13 +9,12 @@ import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
|
|
|
10
9
|
* @protected
|
|
11
10
|
*/
|
|
12
11
|
export const execute = () => {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
// いまの経路を線のメッシュにして、塗りのバッファへ追加する
|
|
13
|
+
const indexCount = meshStrokeCurrentPathUseCase();
|
|
14
|
+
if (indexCount < 0) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
$fillTypes.push("fill");
|
|
18
|
-
const mesh = meshStrokeGenerateUseCase(vertices);
|
|
19
|
-
$addFillBuffer(mesh.buffer);
|
|
20
18
|
// 塗りのインデックスを追加
|
|
21
|
-
$fillBufferIndexes.push(
|
|
19
|
+
$fillBufferIndexes.push(indexCount);
|
|
22
20
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description いまの経路を線のメッシュにして、塗りのバッファへ追加する。
|
|
3
|
+
* 経路を実行環境の側で組み立てていて、線の外周の計算も提供されていれば、
|
|
4
|
+
* 外周の計算もメッシュの生成もそちらで行う。
|
|
5
|
+
* Turns the current path into a stroke mesh and appends it to the fill buffer.
|
|
6
|
+
* If the path was built on the runtime side and the runtime also provides the stroke
|
|
7
|
+
* outline computation, both the outline and the mesh are generated there.
|
|
8
|
+
*
|
|
9
|
+
* @return {number} 追加した頂点数。描く経路が無ければ -1
|
|
10
|
+
* @method
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
export declare const execute: () => number;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { $getVertices } from "../../PathCommand";
|
|
2
|
+
import { execute as meshStrokeGenerateUseCase } from "./MeshStrokeGenerateUseCase";
|
|
3
|
+
import { $addFillBuffer, $reserveFillBuffer, $advanceFillBuffer, $getFillBuffer, $getFillBufferOffset } from "../../Mesh";
|
|
4
|
+
import { $nativeShape, $nativeStroke, $nativePathActive, $setNativePathActive } from "../../NativeShape";
|
|
5
|
+
import { $context, $viewportWidth, $viewportHeight } from "../../WebGLUtil";
|
|
6
|
+
/**
|
|
7
|
+
* @description いまの経路を線のメッシュにして、塗りのバッファへ追加する。
|
|
8
|
+
* 経路を実行環境の側で組み立てていて、線の外周の計算も提供されていれば、
|
|
9
|
+
* 外周の計算もメッシュの生成もそちらで行う。
|
|
10
|
+
* Turns the current path into a stroke mesh and appends it to the fill buffer.
|
|
11
|
+
* If the path was built on the runtime side and the runtime also provides the stroke
|
|
12
|
+
* outline computation, both the outline and the mesh are generated there.
|
|
13
|
+
*
|
|
14
|
+
* @return {number} 追加した頂点数。描く経路が無ければ -1
|
|
15
|
+
* @method
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
export const execute = () => {
|
|
19
|
+
if ($nativePathActive && $nativeStroke && $nativeShape && $nativeShape.strokeSize) {
|
|
20
|
+
$setNativePathActive(false);
|
|
21
|
+
// 曲線の分割数を決める拡大率 (MeshGenerateStrokeOutlineUseCase と同じ計算)
|
|
22
|
+
const matrix = $context.$matrix;
|
|
23
|
+
const scaleX = Math.sqrt(matrix[0] * matrix[0] + matrix[1] * matrix[1]);
|
|
24
|
+
const scaleY = Math.sqrt(matrix[3] * matrix[3] + matrix[4] * matrix[4]);
|
|
25
|
+
const size = $nativeShape.strokeSize($context.thickness / 2, $context.joints, $context.caps, scaleX > scaleY ? scaleX : scaleY);
|
|
26
|
+
if (!size) {
|
|
27
|
+
$nativeShape.reset();
|
|
28
|
+
return -1;
|
|
29
|
+
}
|
|
30
|
+
// MeshFillGenerateUseCase (style = "stroke") と同じ値を渡す
|
|
31
|
+
const colorStyle = $context.$strokeStyle;
|
|
32
|
+
const width = $viewportWidth;
|
|
33
|
+
const height = $viewportHeight;
|
|
34
|
+
$reserveFillBuffer(size);
|
|
35
|
+
const indexCount = $nativeShape.fill($getFillBuffer(), $getFillBufferOffset(), matrix[0] / width, matrix[1] / height, matrix[3] / width, matrix[4] / height, matrix[6] / width, matrix[7] / height, colorStyle[0], colorStyle[1], colorStyle[2], colorStyle[3]);
|
|
36
|
+
$advanceFillBuffer(size);
|
|
37
|
+
return indexCount;
|
|
38
|
+
}
|
|
39
|
+
const vertices = $getVertices(true);
|
|
40
|
+
if (!vertices.length) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
const mesh = meshStrokeGenerateUseCase(vertices);
|
|
44
|
+
$addFillBuffer(mesh.buffer);
|
|
45
|
+
return mesh.indexCount;
|
|
46
|
+
};
|
package/src/NativeShape.d.ts
CHANGED
|
@@ -14,12 +14,21 @@ export interface INativeShape {
|
|
|
14
14
|
fill(target: Float32Array, offset: number, a: number, b: number, c: number, d: number, tx: number, ty: number, red: number, green: number, blue: number, alpha: number): number;
|
|
15
15
|
exportPath(stroke: boolean): Float64Array;
|
|
16
16
|
reset(): void;
|
|
17
|
+
strokeSize?(thickness: number, joints: number, caps: number, pixel_scale: number): number;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* @type {INativeShape | null}
|
|
20
21
|
* @public
|
|
21
22
|
*/
|
|
22
23
|
export declare const $nativeShape: INativeShape | null;
|
|
24
|
+
/**
|
|
25
|
+
* @description 実行環境が線の外周の計算 (strokeSize) も提供しているかどうか
|
|
26
|
+
* Whether the runtime also provides the stroke outline computation (strokeSize)
|
|
27
|
+
*
|
|
28
|
+
* @type {boolean}
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare const $nativeStroke: boolean;
|
|
23
32
|
/**
|
|
24
33
|
* @description 経路を実行環境の側で組み立てている最中かどうか。
|
|
25
34
|
* true の間、JavaScript 側の経路 ($currentPath / $vertices) は空。
|
package/src/NativeShape.js
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
5
|
export const $nativeShape = globalThis.__next2dShape || null;
|
|
6
|
+
/**
|
|
7
|
+
* @description 実行環境が線の外周の計算 (strokeSize) も提供しているかどうか
|
|
8
|
+
* Whether the runtime also provides the stroke outline computation (strokeSize)
|
|
9
|
+
*
|
|
10
|
+
* @type {boolean}
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const $nativeStroke = $nativeShape !== null && typeof $nativeShape.strokeSize === "function";
|
|
6
14
|
/**
|
|
7
15
|
* @description 経路を実行環境の側で組み立てている最中かどうか。
|
|
8
16
|
* true の間、JavaScript 側の経路 ($currentPath / $vertices) は空。
|