From 5200c06cb576c1ee99e69b17452a4542779169e0 Mon Sep 17 00:00:00 2001 From: ienaga Date: Wed, 4 Dec 2024 21:25:48 +0900 Subject: [PATCH] =?UTF-8?q?#154=20DisplayObjectContainer=E3=81=AE=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=82=92=E5=AE=9F=E8=A3=85(WIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 41 +++++++- packages/core/src/Next2D.ts | 2 +- .../display/src/DisplayObjectContainer.ts | 96 +++++++------------ ...yObjectContainerRemoveChildUseCase.test.ts | 1 - ...bjectContainerSetChildIndexUseCase.test.ts | 57 +++++++++++ ...playObjectContainerSetChildIndexUseCase.ts | 32 +++++++ ...jectContainerSwapChildrenAtUseCase.test.ts | 57 +++++++++++ ...layObjectContainerSwapChildrenAtUseCase.ts | 34 +++++++ ...ObjectContainerSwapChildrenUseCase.test.ts | 57 +++++++++++ ...splayObjectContainerSwapChildrenUseCase.ts | 34 +++++++ packages/display/src/Graphics.ts | 63 ------------ packages/display/src/Shape.ts | 66 ------------- packages/media/src/Video.ts | 69 ------------- 13 files changed, 344 insertions(+), 265 deletions(-) create mode 100644 packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase.test.ts create mode 100644 packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase.ts create mode 100644 packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase.test.ts create mode 100644 packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase.ts create mode 100644 packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase.test.ts create mode 100644 packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase.ts diff --git a/index.html b/index.html index 7f7b6439..d544bb64 100644 --- a/index.html +++ b/index.html @@ -14,16 +14,49 @@ const { Sprite, Shape } = next2d.display; const { TextField } = next2d.text; - const { Video } = next2d.media; const { PointerEvent } = next2d.events; const { Rectangle } = next2d.geom; const root = await next2d.createRootMovieClip(480, 480); + + const hitSprite = root.addChild(new Sprite()); + const hitShape = hitSprite.addChild(new Shape()); + hitShape.x = 250; + hitShape.y = 250; + hitShape + .graphics + .beginFill("#ff00ee") + .drawRect(0, 0, 150, 150); const sprite = root.addChild(new Sprite()); - sprite.addChild(new Shape()); - sprite.addChild(new TextField()); - sprite.addChild(new Video()); + sprite.buttonMode = true; + sprite.addEventListener(PointerEvent.POINTER_DOWN, (event) => + { + sprite.startDrag(); + }); + sprite.addEventListener(PointerEvent.POINTER_UP, (event) => + { + sprite.stopDrag(); + }); + + const maskShape = new Shape(); //sprite.addChild(new Shape()); + const viewShape = sprite.addChild(new Shape()); + viewShape.x = 100; + viewShape.y = 100; + viewShape + .graphics + .beginFill("#0eff0e") + .drawRect(0, 0, 100, 100); + + maskShape.x = 100; + maskShape.y = 100; + maskShape + .graphics + .beginFill("#000") + .drawCircle(50, 50, 50); + + // sprite.hitArea = hitSprite; + sprite.mask = maskShape; }); diff --git a/packages/core/src/Next2D.ts b/packages/core/src/Next2D.ts index a4aca06a..6d35f18c 100644 --- a/packages/core/src/Next2D.ts +++ b/packages/core/src/Next2D.ts @@ -180,4 +180,4 @@ export class Next2D width, height, fps, options ); } -} +} \ No newline at end of file diff --git a/packages/display/src/DisplayObjectContainer.ts b/packages/display/src/DisplayObjectContainer.ts index 55fdb598..639bc444 100644 --- a/packages/display/src/DisplayObjectContainer.ts +++ b/packages/display/src/DisplayObjectContainer.ts @@ -8,6 +8,9 @@ import { execute as displayObjectContainerGetChildAtService } from "./DisplayObj import { execute as displayObjectContainerContainsService } from "./DisplayObjectContainer/service/DisplayObjectContainerContainsService"; import { execute as displayObjectContainerGetChildByNameService } from "./DisplayObjectContainer/service/DisplayObjectContainerGetChildByNameService"; import { execute as displayObjectContainerRemoveChildrenUseCase } from "./DisplayObjectContainer/usecase/DisplayObjectContainerRemoveChildrenUseCase"; +import { execute as displayObjectContainerSetChildIndexUseCase } from "./DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase"; +import { execute as displayObjectContainerSwapChildrenUseCase } from "./DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase"; +import { execute as displayObjectContainerSwapChildrenAtUseCase } from "./DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase"; import { $getArray } from "./DisplayObjectUtil"; import { InteractiveObject } from "./InteractiveObject"; @@ -87,6 +90,19 @@ export class DisplayObjectContainer extends InteractiveObject this._$children = $getArray(); } + /** + * @description コンテナのアクティブな子要素を返却 + * Returns the active child elements of the container. + * + * @return {array} + * @method + * @protected + */ + get children (): IDisplayObject[] + { + return this._$children; + } + /** * @description このオブジェクトの子の数を返します。 * Returns the number of children of this object. @@ -215,7 +231,7 @@ export class DisplayObjectContainer extends InteractiveObject * @method * @public */ - getChildIndex (display_object: D): number + getChildIndex (display_object: D): number { return this.children.indexOf(display_object); } @@ -231,7 +247,7 @@ export class DisplayObjectContainer extends InteractiveObject * @method * @public */ - removeChild (display_object: D): void + removeChild (display_object: D): void { displayObjectContainerRemoveChildUseCase(this, display_object); } @@ -269,61 +285,35 @@ export class DisplayObjectContainer extends InteractiveObject * @description 表示オブジェクトコンテナの既存の子の位置を変更します。 * Changes the position of an existing child in the display object container. * - * @param {DisplayObject} child + * @param {DisplayObject} display_object * @param {number} index * @return {void} * @method * @public */ - // setChildIndex ( - // child: DisplayObjectImpl, - // index: number - // ): void { - - // const currentIndex: number = this.getChildIndex(child); - // if (currentIndex === index) { - // return ; - // } - - // const children: DisplayObjectImpl[] = this._$getChildren(); - // children.splice(currentIndex, 1); - // children.splice(index, 0, child); - - // if ($rendererWorker) { - // this._$postChildrenIds(); - // } - - // this._$doChanged(); - // } + setChildIndex ( + display_object: D, + index: number + ): void { + displayObjectContainerSetChildIndexUseCase(this, display_object, index); + } /** * @description 指定された 2 つの子オブジェクトの z 順序(重ね順)を入れ替えます。 * Swaps the z-order (front-to-back order) of the two specified child objects. * - * @param {DisplayObject} child1 - * @param {DisplayObject} child2 + * @param {DisplayObject} display_object1 + * @param {DisplayObject} display_object2 * @return {void} * @method * @public */ - // swapChildren ( - // child1: DisplayObjectImpl, - // child2: DisplayObjectImpl - // ): void { - - // const children: DisplayObjectImpl[] = this._$getChildren(); - // const index1: number = this.getChildIndex(child1); - // const index2: number = this.getChildIndex(child2); - - // children[index1] = child2; - // children[index2] = child1; - - // if ($rendererWorker) { - // this._$postChildrenIds(); - // } - - // this._$doChanged(); - // } + swapChildren ( + display_object1: D, + display_object2: D + ): void { + displayObjectContainerSwapChildrenUseCase(this, display_object1, display_object2); + } /** * @description 子リスト内の指定されたインデックス位置に該当する 2 つの子オブジェクトの z 順序(重ね順)を入れ替えます。 @@ -336,24 +326,8 @@ export class DisplayObjectContainer extends InteractiveObject * @method * @public */ - // swapChildrenAt (index1: number, index2: number): void - // { - // this.swapChildren( - // this.getChildAt(index1), - // this.getChildAt(index2) - // ); - // } - - /** - * @description コンテナのアクティブな子要素を返却 - * Returns the active child elements of the container. - * - * @return {array} - * @method - * @protected - */ - get children (): IDisplayObject[] + swapChildrenAt (index1: number, index2: number): void { - return this._$children; + displayObjectContainerSwapChildrenAtUseCase(this, index1, index2); } } \ No newline at end of file diff --git a/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerRemoveChildUseCase.test.ts b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerRemoveChildUseCase.test.ts index 7e5cd359..30d19b8d 100644 --- a/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerRemoveChildUseCase.test.ts +++ b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerRemoveChildUseCase.test.ts @@ -35,5 +35,4 @@ describe("DisplayObjectContainerRemoveChildUseCase.js test", () => expect(container.changed).toBe(true); }); - }); \ No newline at end of file diff --git a/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase.test.ts b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase.test.ts new file mode 100644 index 00000000..38b673c4 --- /dev/null +++ b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase.test.ts @@ -0,0 +1,57 @@ +import { execute } from "./DisplayObjectContainerSetChildIndexUseCase"; +import { Shape } from "../../Shape"; +import { DisplayObjectContainer } from "../../DisplayObjectContainer"; +import { describe, expect, it } from "vitest"; + +describe("DisplayObjectContainerSetChildIndexUseCase.js test", () => +{ + it("execute test case1", () => + { + const container = new DisplayObjectContainer(); + const shape0 = container.addChild(new Shape()); + const shape1 = container.addChild(new Shape()); + const shape2 = container.addChild(new Shape()); + const shape3 = container.addChild(new Shape()); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape1); + expect(container.children[2]).toBe(shape2); + expect(container.children[3]).toBe(shape3); + + container.changed = false; + expect(container.changed).toBe(false); + + execute(container, shape1, 2); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape2); + expect(container.children[2]).toBe(shape1); + expect(container.children[3]).toBe(shape3); + expect(container.changed).toBe(true); + }); + + it("execute test case2", () => + { + const container = new DisplayObjectContainer(); + const shape0 = container.addChild(new Shape()); + const shape1 = container.addChild(new Shape()); + const shape2 = container.addChild(new Shape()); + const shape3 = container.addChild(new Shape()); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape1); + expect(container.children[2]).toBe(shape2); + expect(container.children[3]).toBe(shape3); + + container.changed = false; + expect(container.changed).toBe(false); + + execute(container, shape0, 3); + + expect(container.children[0]).toBe(shape1); + expect(container.children[1]).toBe(shape2); + expect(container.children[2]).toBe(shape3); + expect(container.children[3]).toBe(shape0); + expect(container.changed).toBe(true); + }); +}); \ No newline at end of file diff --git a/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase.ts b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase.ts new file mode 100644 index 00000000..51f2ae26 --- /dev/null +++ b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSetChildIndexUseCase.ts @@ -0,0 +1,32 @@ +import type { DisplayObject } from "../../DisplayObject"; +import type { DisplayObjectContainer } from "../../DisplayObjectContainer"; +import { execute as displayObjectApplyChangesService } from "../../DisplayObject/service/DisplayObjectApplyChangesService"; + +/** + * @description 指定されたインデックスに子を移動します + * Moves the child to the specified index + * + * @param {DisplayObjectContainer} display_object_container + * @param {DisplayObject} display_object + * @param {number} index + * @return {void} + * @method + * @protected + */ +export const execute = ( + display_object_container: C, + display_object: D, + index: number +): void => { + + const currentIndex = display_object_container.getChildIndex(display_object); + if (currentIndex === -1 || currentIndex === index) { + return ; + } + + const children = display_object_container.children; + children.splice(currentIndex, 1); + children.splice(index, 0, display_object); + + displayObjectApplyChangesService(display_object_container); +}; \ No newline at end of file diff --git a/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase.test.ts b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase.test.ts new file mode 100644 index 00000000..1b9cdbe2 --- /dev/null +++ b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase.test.ts @@ -0,0 +1,57 @@ +import { execute } from "./DisplayObjectContainerSwapChildrenAtUseCase"; +import { Shape } from "../../Shape"; +import { DisplayObjectContainer } from "../../DisplayObjectContainer"; +import { describe, expect, it } from "vitest"; + +describe("DisplayObjectContainerSwapChildrenAtUseCase.js test", () => +{ + it("execute test case1", () => + { + const container = new DisplayObjectContainer(); + const shape0 = container.addChild(new Shape()); + const shape1 = container.addChild(new Shape()); + const shape2 = container.addChild(new Shape()); + const shape3 = container.addChild(new Shape()); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape1); + expect(container.children[2]).toBe(shape2); + expect(container.children[3]).toBe(shape3); + + container.changed = false; + expect(container.changed).toBe(false); + + execute(container, 1, 2); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape2); + expect(container.children[2]).toBe(shape1); + expect(container.children[3]).toBe(shape3); + expect(container.changed).toBe(true); + }); + + it("execute test case2", () => + { + const container = new DisplayObjectContainer(); + const shape0 = container.addChild(new Shape()); + const shape1 = container.addChild(new Shape()); + const shape2 = container.addChild(new Shape()); + const shape3 = container.addChild(new Shape()); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape1); + expect(container.children[2]).toBe(shape2); + expect(container.children[3]).toBe(shape3); + + container.changed = false; + expect(container.changed).toBe(false); + + execute(container, 0, 3); + + expect(container.children[0]).toBe(shape3); + expect(container.children[1]).toBe(shape1); + expect(container.children[2]).toBe(shape2); + expect(container.children[3]).toBe(shape0); + expect(container.changed).toBe(true); + }); +}); \ No newline at end of file diff --git a/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase.ts b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase.ts new file mode 100644 index 00000000..7e2258bd --- /dev/null +++ b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenAtUseCase.ts @@ -0,0 +1,34 @@ +import type { DisplayObjectContainer } from "../../DisplayObjectContainer"; +import { execute as displayObjectApplyChangesService } from "../../DisplayObject/service/DisplayObjectApplyChangesService"; + +/** + * @description 子リスト内の指定されたインデックス位置に該当する 2 つの子オブジェクトの z 順序(重ね順)を入れ替えます。 + * Swaps the z-order (front-to-back order) of the child objects at + * the two specified index positions in the child list. + * @param {DisplayObjectContainer} display_object_container + * @param {number} index1 + * @param {number} index2 + * @return {void} + * @method + * @protected + */ +export const execute = ( + display_object_container: C, + index1: number, + index2: number +): void => { + + const children = display_object_container.children; + + const displayObject1 = children[index1]; + const displayObject2 = children[index2]; + + if (!displayObject1 || !displayObject2) { + return ; + } + + children[index1] = displayObject2; + children[index2] = displayObject1; + + displayObjectApplyChangesService(display_object_container); +}; \ No newline at end of file diff --git a/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase.test.ts b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase.test.ts new file mode 100644 index 00000000..9f8b1de8 --- /dev/null +++ b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase.test.ts @@ -0,0 +1,57 @@ +import { execute } from "./DisplayObjectContainerSwapChildrenUseCase"; +import { Shape } from "../../Shape"; +import { DisplayObjectContainer } from "../../DisplayObjectContainer"; +import { describe, expect, it } from "vitest"; + +describe("DisplayObjectContainerSwapChildrenUseCase.js test", () => +{ + it("execute test case1", () => + { + const container = new DisplayObjectContainer(); + const shape0 = container.addChild(new Shape()); + const shape1 = container.addChild(new Shape()); + const shape2 = container.addChild(new Shape()); + const shape3 = container.addChild(new Shape()); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape1); + expect(container.children[2]).toBe(shape2); + expect(container.children[3]).toBe(shape3); + + container.changed = false; + expect(container.changed).toBe(false); + + execute(container, shape1, shape2); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape2); + expect(container.children[2]).toBe(shape1); + expect(container.children[3]).toBe(shape3); + expect(container.changed).toBe(true); + }); + + it("execute test case2", () => + { + const container = new DisplayObjectContainer(); + const shape0 = container.addChild(new Shape()); + const shape1 = container.addChild(new Shape()); + const shape2 = container.addChild(new Shape()); + const shape3 = container.addChild(new Shape()); + + expect(container.children[0]).toBe(shape0); + expect(container.children[1]).toBe(shape1); + expect(container.children[2]).toBe(shape2); + expect(container.children[3]).toBe(shape3); + + container.changed = false; + expect(container.changed).toBe(false); + + execute(container, shape0, shape3); + + expect(container.children[0]).toBe(shape3); + expect(container.children[1]).toBe(shape1); + expect(container.children[2]).toBe(shape2); + expect(container.children[3]).toBe(shape0); + expect(container.changed).toBe(true); + }); +}); \ No newline at end of file diff --git a/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase.ts b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase.ts new file mode 100644 index 00000000..2fe02415 --- /dev/null +++ b/packages/display/src/DisplayObjectContainer/usecase/DisplayObjectContainerSwapChildrenUseCase.ts @@ -0,0 +1,34 @@ +import type { DisplayObject } from "../../DisplayObject"; +import type { DisplayObjectContainer } from "../../DisplayObjectContainer"; +import { execute as displayObjectApplyChangesService } from "../../DisplayObject/service/DisplayObjectApplyChangesService"; + +/** + * @description 指定された2つの子の表示順を入れ替えます + * Swaps the display order of the two specified children + * + * @param {DisplayObjectContainer} display_object_container + * @param {DisplayObject} display_object1 + * @param {DisplayObject} display_object2 + * @return {void} + * @method + * @protected + */ +export const execute = ( + display_object_container: C, + display_object1: D, + display_object2: D +): void => { + + const index1 = display_object_container.getChildIndex(display_object1); + const index2 = display_object_container.getChildIndex(display_object2); + + if (index1 === -1 || index2 === -1) { + return ; + } + + const children = display_object_container.children; + children[index1] = display_object2; + children[index2] = display_object1; + + displayObjectApplyChangesService(display_object_container); +}; \ No newline at end of file diff --git a/packages/display/src/Graphics.ts b/packages/display/src/Graphics.ts index 14e2e5e4..0b0a482d 100644 --- a/packages/display/src/Graphics.ts +++ b/packages/display/src/Graphics.ts @@ -3,7 +3,6 @@ import type { IJointStyle } from "./interface/IJointStyle"; import type { IGradientType } from "./interface/IGradientType"; import type { ISpreadMethod } from "./interface/ISpreadMethod"; import type { IInterpolationMethod } from "./interface/IInterpolationMethod"; -import type { IPlayerHitObject } from "./interface/IPlayerHitObject"; import type { BitmapData } from "./BitmapData"; import type { Matrix } from "@next2d/geom"; import { GraphicsBitmapFill } from "./GraphicsBitmapFill"; @@ -14,7 +13,6 @@ import { execute as graphicsDrawEllipseService } from "./Graphics/service/Graphi import { execute as graphicsDrawRectService } from "./Graphics/service/GraphicsDrawRectService"; import { execute as graphicsDrawRoundRectService } from "./Graphics/service/GraphicsDrawRoundRectService"; import { execute as graphicsToNumberArrayService } from "./Graphics/service/GraphicsToNumberArrayService"; -import { execute as graphicsHitTestService } from "./Graphics/service/GraphicsHitTestService"; import { $getArray, $poolArray, @@ -1445,67 +1443,6 @@ export class Graphics return this; } - /** - * @description 指定のxy座標が描画範囲にヒットしてるかの判定 - * Judges whether the specified xy coordinate hits the drawing range. - * - * @param {CanvasRenderingContext2D} context - * @param {Float32Array} matrix - * @param {object} options - * @return {boolean} - * @method - * @private - */ - _$hit ( - context: CanvasRenderingContext2D, - matrix: Float32Array, - options: IPlayerHitObject - ): boolean { - - // fixed logic - if (this._$hasLineEnabled) { - this.endLine(); - } - - // fixed logic - if (this._$hasFillEnabled) { - this.endFill(); - } - - if (!this.$recodes) { - return false; - } - - context.beginPath(); - context.setTransform( - matrix[0], matrix[1], matrix[2], - matrix[3], matrix[4], matrix[5] - ); - - return graphicsHitTestService(context, this.$recodes, options); - } - - // /** - // * @return {object} - // * @method - // * @private - // */ - // _$getBounds (): BoundsImpl - // { - // const displayObject: DisplayObjectImpl = this._$displayObject; - // if (displayObject && displayObject._$bounds) { - // return $getBoundsObject( - // displayObject._$bounds.xMin, displayObject._$bounds.xMax, - // displayObject._$bounds.yMin, displayObject._$bounds.yMax - // ); - // } - - // return $getBoundsObject( - // this.xMin, this.xMax, - // this.yMin, this.yMax - // ); - // } - /** * @description この Graphics オブジェクトに描画されているパス情報をFloat32Arrayで返却 * Returns the path information drawn to this Graphics object in Float32Array. diff --git a/packages/display/src/Shape.ts b/packages/display/src/Shape.ts index d61b4b6d..e9e8f5c2 100644 --- a/packages/display/src/Shape.ts +++ b/packages/display/src/Shape.ts @@ -1,4 +1,3 @@ -import type { IPlayerHitObject } from "./interface/IPlayerHitObject"; import { DisplayObject } from "./DisplayObject"; import { Graphics } from "./Graphics"; import { execute as shapeClearBitmapBufferService } from "./Shape/usecase/ShapeClearBitmapBufferUseCase"; @@ -201,69 +200,4 @@ export class Shape extends DisplayObject buffer ); } - - /** - * @description マウスイベントのヒットテストを行います。 - * Performs a hit test on a display object by testing a point against all visible children. - * - * @param {CanvasRenderingContext2D} context - * @param {Float32Array} matrix - * @param {object} options - * @return {boolean} - * @method - * @private - */ - _$mouseHit ( - context: CanvasRenderingContext2D, - matrix: Float32Array, - options: IPlayerHitObject - ): boolean { - - if (!this.visible) { - return false; - } - - return this._$hit(context, matrix, options); - } - - /** - * @param {CanvasRenderingContext2D} context - * @param {Float32Array} matrix - * @param {object} options - * @return {boolean} - * @method - * @private - */ - _$hit ( - context: CanvasRenderingContext2D, - matrix: Float32Array, - options: IPlayerHitObject - ): boolean { - - const graphics: Graphics | null = this._$graphics; - if (!graphics || !graphics.isDrawable) { - return false; - } - - const multiMatrix: Float32Array = matrix; - // const rawMatrix: Float32Array = this._$transform._$rawMatrix(); - // if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0 - // || rawMatrix[2] !== 0 || rawMatrix[3] !== 1 - // || rawMatrix[4] !== 0 || rawMatrix[5] !== 0 - // ) { - // multiMatrix = $multiplicationMatrix(matrix, rawMatrix); - // } - - const hit = graphics._$hit( - context, - multiMatrix, - options - ); - - // if (multiMatrix !== matrix) { - // $poolFloat32Array6(multiMatrix); - // } - - return hit; - } } \ No newline at end of file diff --git a/packages/media/src/Video.ts b/packages/media/src/Video.ts index d1424422..b184a977 100644 --- a/packages/media/src/Video.ts +++ b/packages/media/src/Video.ts @@ -365,73 +365,4 @@ export class Video extends DisplayObject this.dispatchEvent(new VideoEvent(VideoEvent.SEEK)); } } - - // /** - // * @param {CanvasRenderingContext2D} context - // * @param {Float32Array} matrix - // * @param {object} options - // * @return {boolean} - // * @method - // * @private - // */ - // _$mouseHit ( - // context: CanvasRenderingContext2D, - // matrix: Float32Array, - // options: PlayerHitObjectImpl - // ): boolean { - - // if (!this._$visible) { - // return false; - // } - - // return this._$hit(context, matrix, options); - // } - - // /** - // * @param {CanvasRenderingContext2D} context - // * @param {array} matrix - // * @param {object} options - // * @return {boolean} - // * @method - // * @private - // */ - // _$hit ( - // context: CanvasRenderingContext2D, - // matrix: Float32Array, - // options: PlayerHitObjectImpl - // ): boolean { - - // let multiMatrix: Float32Array = matrix; - // const rawMatrix: Float32Array = this._$transform._$rawMatrix(); - // if (rawMatrix !== $MATRIX_ARRAY_IDENTITY) { - // multiMatrix = $multiplicationMatrix(matrix, rawMatrix); - // } - - // const baseBounds: BoundsImpl = this._$getBounds(null); - - // const bounds: BoundsImpl = $boundsMatrix(baseBounds, multiMatrix); - // const xMax = +bounds.xMax; - // const xMin = +bounds.xMin; - // const yMax = +bounds.yMax; - // const yMin = +bounds.yMin; - // $poolBoundsObject(bounds); - // $poolBoundsObject(baseBounds); - - // const width: number = Math.ceil(Math.abs(xMax - xMin)); - // const height: number = Math.ceil(Math.abs(yMax - yMin)); - - // context.setTransform(1, 0, 0, 1, xMin, yMin); - // context.beginPath(); - // context.moveTo(0, 0); - // context.lineTo(width, 0); - // context.lineTo(width, height); - // context.lineTo(0, height); - // context.lineTo(0, 0); - - // if (multiMatrix !== matrix) { - // $poolFloat32Array6(multiMatrix); - // } - - // return context.isPointInPath(options.x, options.y); - // } } \ No newline at end of file