-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
726 additions
and
85 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
packages/display/src/DisplayObject/usecase/DisplayObjectIsMaskReflectedInDisplayUseCase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import type { DisplayObject } from "../../DisplayObject"; | ||
import type { Shape } from "../../Shape"; | ||
import { Matrix } from "@next2d/geom"; | ||
import { execute as shapeGetCalcBoundsMatrixUseCase } from "../../Shape/usecase/ShapeGetCalcBoundsMatrixUseCase"; | ||
import { execute as displayObjectGetRawMatrixUseCase } from "../../DisplayObject/usecase/DisplayObjectGetRawMatrixUseCase"; | ||
import { | ||
$getArray, | ||
$poolArray | ||
} from "@next2d/share"; | ||
|
||
/** | ||
* @description DisplayObjectのマスク描画範囲を計算して、マスク描画が実行可能かどうかを返します。 | ||
* Calculate the mask drawing area of DisplayObject and return whether the mask drawing is executable. | ||
* | ||
* @param {DisplayObject} display_object | ||
* @param {Float32Array} matrix | ||
* @param {number} renderer_width | ||
* @param {number} renderer_height | ||
* @param {number} point_x | ||
* @param {number} point_y | ||
* @return {boolean} | ||
* @method | ||
* @protected | ||
*/ | ||
export const execute = <D extends DisplayObject>( | ||
display_object: D, | ||
matrix: Float32Array, | ||
renderer_width: number, | ||
renderer_height: number, | ||
point_x: number, | ||
point_y: number | ||
): number[] | null => { | ||
|
||
let bounds: number[] | null = null; | ||
|
||
const rawMatrix = displayObjectGetRawMatrixUseCase(display_object); | ||
const tMatrix = rawMatrix | ||
? Matrix.multiply(matrix, rawMatrix) | ||
: matrix; | ||
|
||
switch (true) { | ||
|
||
case display_object.isShape: | ||
bounds = shapeGetCalcBoundsMatrixUseCase( | ||
(display_object as unknown as Shape).graphics, tMatrix | ||
); | ||
break; | ||
|
||
case display_object.isContainerEnabled: | ||
// todo | ||
break; | ||
|
||
case display_object.isText: | ||
// todo | ||
break; | ||
|
||
case display_object.isVideo: | ||
// todo | ||
break; | ||
|
||
default: | ||
break; | ||
|
||
} | ||
|
||
if (tMatrix !== matrix) { | ||
Matrix.release(tMatrix); | ||
} | ||
|
||
if (!bounds) { | ||
return null; | ||
} | ||
|
||
const xMin = bounds[0]; | ||
const xMax = bounds[2]; | ||
const width = Math.abs(xMax - xMin); | ||
if (!width) { | ||
return null; | ||
} | ||
|
||
const yMin = bounds[1]; | ||
const yMax = bounds[3]; | ||
const height = Math.abs(yMax - yMin); | ||
if (!height) { | ||
return null; | ||
} | ||
|
||
if (point_x > xMin + width | ||
|| point_y > yMin + height | ||
|| xMin > renderer_width | ||
|| yMin > renderer_height | ||
) { | ||
return null; | ||
} | ||
|
||
return bounds; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/display/src/Shape/usecase/ShapeGenerateClipQueueUseCase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { Shape } from "../../Shape"; | ||
import { Matrix } from "@next2d/geom"; | ||
import { $RENDERER_SHAPE_TYPE } from "../../DisplayObjectUtil"; | ||
import { execute as displayObjectGetRawMatrixUseCase } from "../../DisplayObject/usecase/DisplayObjectGetRawMatrixUseCase"; | ||
|
||
/** | ||
* @description renderer workerに渡すShapeのマスク描画データを生成 | ||
* Generate mask drawing data of Shape to pass to renderer worker | ||
* | ||
* @param {Shape} shape | ||
* @param {array} render_queue | ||
* @param {Float32Array} matrix | ||
* @return {void} | ||
* @method | ||
* @protected | ||
*/ | ||
export const execute = ( | ||
shape: Shape, | ||
render_queue: number[], | ||
matrix: Float32Array | ||
): void => { | ||
|
||
render_queue.push($RENDERER_SHAPE_TYPE); | ||
|
||
// transformed matrix(tMatrix) | ||
const rawMatrix = displayObjectGetRawMatrixUseCase(shape); | ||
const tMatrix = rawMatrix | ||
? Matrix.multiply(matrix, rawMatrix) | ||
: matrix; | ||
|
||
render_queue.push(...tMatrix); | ||
if (tMatrix !== matrix) { | ||
Matrix.release(tMatrix); | ||
} | ||
|
||
const hasGrid: boolean = rawMatrix && shape.scale9Grid | ||
? Math.abs(rawMatrix[1]) < 0.001 && Math.abs(rawMatrix[2]) < 0.0001 | ||
: false; | ||
|
||
render_queue.push(+hasGrid); | ||
|
||
const buffer = shape.graphics.buffer; | ||
render_queue.push(buffer.length, ...buffer); | ||
}; |
Oops, something went wrong.