repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
effects-runtime
github_2023
galacean
typescript
VFXItem.beginPlay
beginPlay () { this.isDuringPlay = true; if (this.composition && this.active && !this.isEnabled) { this.onEnable(); } for (const child of this.children) { if (!child.isDuringPlay) { child.beginPlay(); } } }
/** * @internal */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L567-L580
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VFXItem.onActiveChanged
onActiveChanged () { if (!this.isEnabled) { this.onEnable(); } else { this.onDisable(); } }
/** * @internal */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L585-L591
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VFXItem.onEnable
onEnable () { this.isEnabled = true; for (const component of this.components) { if (component.enabled && !component.isStartCalled) { component.onStart(); component.isStartCalled = true; } } for (const component of this.components) { if (component.enabled && !component.i...
/** * @internal */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L596-L609
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VFXItem.onDisable
onDisable () { this.isEnabled = false; for (const component of this.components) { if (component.enabled && component.isEnableCalled) { component.disable(); } } }
/** * @internal */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L614-L621
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VFXItem.dispose
override dispose (): void { this.resetChildrenParent(); if (this.composition) { this.composition.destroyItem(this); // component 调用 dispose() 会将自身从 this.components 数组删除,slice() 避免迭代错误 for (const component of this.components.slice()) { component.dispose(); } this.components...
/** * 销毁元素 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L723-L737
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BaseRenderComponent.constructor
constructor (engine: Engine) { super(engine); this.renderer = { renderMode: spec.RenderMode.MESH, blending: spec.BlendingMode.ALPHA, texture: this.engine.emptyTexture, occlusion: false, transparentOcclusion: false, side: spec.SideMode.DOUBLE, mask: 0, maskMode: s...
/** * * @param engine */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/base-render-component.ts#L72-L95
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BaseRenderComponent.setVisible
setVisible (visible: boolean) { this.visible = visible; }
/** * 设置当前 Mesh 的可见性。 * @param visible - true:可见,false:不可见 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/base-render-component.ts#L101-L103
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BaseRenderComponent.getVisible
getVisible (): boolean { return this.visible; }
/** * 获取当前 Mesh 的可见性。 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/base-render-component.ts#L107-L109
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BaseRenderComponent.setColor
setColor (color: spec.vec4) { this.color = color; this.material.setVector4('_Color', new Vector4().setFromArray(color)); }
/** * 设置当前图层的颜色 * > Tips: 透明度也属于颜色的一部分,当有透明度/颜色 K 帧变化时,该 API 会失效 * @since 2.0.0 * @param color - 颜色值 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/base-render-component.ts#L117-L120
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BaseRenderComponent.setTexture
setTexture (texture: Texture) { this.renderer.texture = texture; this.material.setTexture('_MainTex', texture); }
/** * 设置当前 Mesh 的纹理 * @since 2.0.0 * @param texture - 纹理对象 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/base-render-component.ts#L127-L130
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BaseRenderComponent.setAnimationTime
setAnimationTime (time: number) { this.frameAnimationTime = time; this.isManualTimeSet = true; }
/** * @internal */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/base-render-component.ts#L135-L138
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BaseRenderComponent.getBoundingBox
getBoundingBox (): BoundingBoxTriangle | void { if (!this.item) { return; } const worldMatrix = this.transform.getWorldMatrix(); const triangles = trianglesFromRect(Vector3.ZERO, 0.5 * this.transform.size.x, 0.5 * this.transform.size.y); triangles.forEach(triangle => { worldMatrix.trans...
/** * 获取图层包围盒的类型和世界坐标 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/base-render-component.ts#L344-L361
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
MeshComponent.getHitTestParams
getHitTestParams = (force?: boolean): HitTestTriangleParams | void => { const worldMatrix = this.transform.getWorldMatrix(); this.meshCollider.setGeometry(this.geometry, worldMatrix); const area = this.meshCollider.getBoundingBoxData(); if (area) { return { type: area.type, trian...
// TODO 点击测试后续抽象一个 Collider 组件
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/mesh-component.ts
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShapeComponent.constructor
constructor (engine: Engine) { super(engine); if (!this.geometry) { this.geometry = Geometry.create(engine, { attributes: { aPos: { type: glContext.FLOAT, size: 3, data: new Float32Array([ -0.5, 0.5, 0, //左上 -0.5, -0.5, 0, ...
/** * * @param engine */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/components/shape-component.ts#L63-L105
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SceneTicking.addComponent
addComponent (obj: Component): void { if (obj.onUpdate !== Component.prototype.onUpdate) { this.update.addComponent(obj); } if (obj.onLateUpdate !== Component.prototype.onLateUpdate) { this.lateUpdate.addComponent(obj); } }
/** * * @param obj */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition/scene-ticking.ts#L14-L21
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SceneTicking.removeComponent
removeComponent (obj: Component): void { if (obj.onUpdate !== Component.prototype.onUpdate) { this.update.removeComponent(obj); } if (obj.onLateUpdate !== Component.prototype.onLateUpdate) { this.lateUpdate.removeComponent(obj); } }
/** * * @param obj */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition/scene-ticking.ts#L27-L34
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SceneTicking.clear
clear (): void { this.update.clear(); this.lateUpdate.clear(); }
/** * */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition/scene-ticking.ts#L39-L42
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
EventEmitter.getListeners
off = <E extends keyof T & string> ( eventName: E, listener: EventEmitterListener<T[E]>, ): void => { if (!this.listeners[eventName]) { return; } this.listeners[eventName] = this.listeners[eventName].filter(({ listener: l }) => l !== listener); }
/** * 监听事件 * @param eventName - 事件名称 * @param listener - 事件监听器 * @param options - 事件监听器选项 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/events/event-emitter.ts
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
calcBezier
function calcBezier (t: number, a1: number, a2: number) { return ((A(a1, a2) * t + B(a1, a2)) * t + C(a1)) * t; }
// A * t ^ 3 + B * t ^ 2 + C * t
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/math/bezier.ts#L33-L35
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
getSlope
function getSlope (t: number, a1: number, a2: number) { return 3.0 * A(a1, a2) * t * t + 2.0 * B(a1, a2) * t + C(a1); }
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/math/bezier.ts#L38-L40
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BezierPath.getPointInPercent
getPointInPercent (percent: number) { const bezierData = this.lengthData; if (percent === 0) { return bezierData.points[0].point.clone().add(this.interval); } if (decimalEqual(1 - percent, 0)) { return bezierData.points[CURVE_SEGMENTS - 1].point.clone().add(this.interval); } if (de...
/** * 获取路径在指定比例长度上点的坐标 * @param percent 路径长度的比例 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/math/bezier.ts#L160-L226
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BezierQuat.getPointInPercent
getPointInPercent (percent: number) { if (percent === 0) { return this.temp.copyFrom(this.p1); } if (decimalEqual(1 - percent, 0)) { return this.temp.copyFrom(this.p2); } QuaternionInner.slerpFlat(this.temp, this.p1, this.p2, percent); return this.temp; }
/** * 获取路径在指定比例长度上点的坐标 * @param percent 路径长度的比例 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/math/bezier.ts#L242-L254
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
RandomVectorValue.map
override map (func: any) { this.min = this.min.map(func); this.max = this.max.map(func); return this; }
// TODO:
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/math/value-getters/value-getter.ts#L195-L200
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BezierCurve.getCurveIntegrateValue
getCurveIntegrateValue (curveKey: string, time: number) { const curveInfo = this.curveMap[curveKey]; const [p0] = curveInfo.points; const timeInterval = curveInfo.timeInterval; const valueInterval = curveInfo.valueInterval; const segments = 20; let total = 0; const h = (time - p0.x) / segmen...
// 速度变化曲线面板移除后下线
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/math/value-getters/value-getter.ts#L514-L540
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TransformAnimationPlayable.sampleAnimation
private sampleAnimation () { const boundItem = this.boundObject; const duration = boundItem.duration; let life = this.time / duration; life = life < 0 ? 0 : (life > 1 ? 1 : life); if (this.sizeXOverLifetime) { tempSize.x = this.sizeXOverLifetime.getValue(life); if (this.sizeSeparateAxe...
/** * 应用时间轴K帧数据到对象 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/cal/calculate-vfx-item.ts#L152-L203
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Playable.prepareFrame
prepareFrame (context: FrameContext) { }
// }
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/cal/playable-graph.ts#L141-L143
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
PlayableOutput.prepareFrame
prepareFrame () { }
// }
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/cal/playable-graph.ts#L205-L207
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ParticleMesh.getPointColor
getPointColor (index: number) { const data = this.geometry.getAttributeData('aRot'); const i = index * 32 + 4; assertExist(data); return [data[i], data[i + 1], data[i + 2], data[i + 3]]; }
// }
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/particle/particle-mesh.ts#L422-L429
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ParticleSystem.setColor
setColor (r: number, g: number, b: number, a: number) { const material = this.renderer.particleMesh.mesh.material; const geometry = this.renderer.particleMesh.mesh.geometry; const originalColor = material.getVector4('uOpacityOverLifetimeValue')?.toArray() || [1, 1, 1, 1]; material.setVector4('uOpacityO...
/** * @internal */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/particle/particle-system.ts#L296-L310
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ParticleSystem.getPointPositionByIndex
getPointPositionByIndex (index: number): Vector3 | null { const point = this.particleLink.getNodeByIndex(index); if (!point) { console.error('Get point error.'); return null; } else { return this.getPointPosition(point.content[3]); } }
/** * 通过索引获取指定index粒子当前时刻的位置 * @params index - 粒子索引 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/particle/particle-system.ts#L615-L625
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ParticleSystem.getPointPosition
getPointPosition (point: Point): Vector3 { const { transform, vel, lifetime, delay, gravity = [], } = point; const forceTarget = this.options.forceTarget; const time = this.lastUpdate - delay; const tempPos = new Vector3(); const acc = Vector3.fromArray(gravity); ...
/** * 通过粒子参数获取当前时刻粒子的位置 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/particle/particle-system.ts#L630-L659
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
calculateDirection
function calculateDirection (prePoint: Vector3 | undefined, point: Vector3, nextPoint?: Vector3): vec3 { const dir = tempDir; if (!prePoint && !nextPoint) { return [0, 0, 0]; } else if (!prePoint) { dir.subtractVectors(nextPoint!, point); } else if (!nextPoint) { dir.subtractVectors(point, prePoint...
// TODO: prePoint 可选,point 必选,顺序有问题
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/particle/trail-mesh.ts#L431-L449
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
begin
function begin ( sX: number, sY: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, eX: number, eY: number, points: number[], distanceTolerance: number, ) { // dont need to actually ad this! // points.push(sX, sY); recursive(sX, sY, cp1x, cp1y, cp2x, cp2y, eX, eY, points, distanceToleranc...
//// Based on:
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/build-adaptive-bezier.ts#L39-L51
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
recursive
function recursive ( x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, points: number[], distanceTolerance: number, level: number, ) { if (level > RECURSION_LIMIT) { return; } const pi = Math.PI; // Calculate all the mid-points of the line segments /...
// eslint-disable-next-line max-params
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/build-adaptive-bezier.ts#L54-L215
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Ellipse.constructor
constructor (x = 0, y = 0, halfWidth = 0, halfHeight = 0) { super(); this.x = x; this.y = y; this.halfWidth = halfWidth; this.halfHeight = halfHeight; }
/** * @param x - The X coordinate of the center of this ellipse * @param y - The Y coordinate of the center of this ellipse * @param halfWidth - The half width of this ellipse * @param halfHeight - The half height of this ellipse */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/ellipse.ts#L43-L49
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Ellipse.clone
clone (): Ellipse { return new Ellipse(this.x, this.y, this.halfWidth, this.halfHeight); }
/** * Creates a clone of this Ellipse instance * @returns {Ellipse} A copy of the ellipse */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/ellipse.ts#L55-L57
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Ellipse.contains
contains (x: number, y: number): boolean { if (this.halfWidth <= 0 || this.halfHeight <= 0) { return false; } // normalize the coords to an ellipse with center 0,0 let normx = ((x - this.x) / this.halfWidth); let normy = ((y - this.y) / this.halfHeight); normx *= normx; normy *= norm...
/** * Checks whether the x and y coordinates given are contained within this ellipse * @param x - The X coordinate of the point to test * @param y - The Y coordinate of the point to test * @returns Whether the x/y coords are within this ellipse */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/ellipse.ts#L65-L78
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Ellipse.strokeContains
strokeContains (x: number, y: number, width: number): boolean { const { halfWidth, halfHeight } = this; if (halfWidth <= 0 || halfHeight <= 0) { return false; } const halfStrokeWidth = width / 2; const innerA = halfWidth - halfStrokeWidth; const innerB = halfHeight - halfStrokeWidth; ...
/** * Checks whether the x and y coordinates given are contained within this ellipse including stroke * @param x - The X coordinate of the point to test * @param y - The Y coordinate of the point to test * @param width * @returns Whether the x/y coords are within this ellipse */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/ellipse.ts#L87-L109
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Ellipse.copyFrom
copyFrom (ellipse: Ellipse): this { this.x = ellipse.x; this.y = ellipse.y; this.halfWidth = ellipse.halfWidth; this.halfHeight = ellipse.halfHeight; return this; }
/** * Copies another ellipse to this one. * @param ellipse - The ellipse to copy from. * @returns Returns itself. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/ellipse.ts#L132-L139
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Ellipse.copyTo
copyTo (ellipse: Ellipse): Ellipse { ellipse.copyFrom(this); return ellipse; }
/** * Copies this ellipse to another one. * @param ellipse - The ellipse to copy to. * @returns Returns given parameter. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/ellipse.ts#L146-L150
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
GraphicsPath.shapePath
get shapePath (): ShapePath { if (!this._shapePath) { this._shapePath = new ShapePath(this); } if (this.dirty) { this.dirty = false; this._shapePath.buildPath(); } return this._shapePath; }
/** * Provides access to the internal shape path, ensuring it is up-to-date with the current instructions. * @returns The `ShapePath` instance associated with this `GraphicsPath`. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/graphics-path.ts#L20-L31
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
GraphicsPath.bezierCurveTo
bezierCurveTo ( cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number, smoothness?: number, ): GraphicsPath { this.instructions.push({ action: 'bezierCurveTo', data: [cp1x, cp1y, cp2x, cp2y, x, y, smoothness] }); this.dirty = true; return this; }
/** * Adds a cubic Bezier curve to the path. * It requires three points: the first two are control points and the third one is the end point. * The starting point is the last point in the current path. * @param cp1x - The x-coordinate of the first control point. * @param cp1y - The y-coordinate of the fi...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/graphics-path.ts#L46-L56
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
GraphicsPath.moveTo
moveTo (x: number, y: number): GraphicsPath { this.instructions.push({ action: 'moveTo', data: [x, y] }); this.dirty = true; return this; }
/** * Sets the starting point for a new sub-path. Any subsequent drawing commands are considered part of this path. * @param x - The x-coordinate for the starting point. * @param y - The y-coordinate for the starting point. * @returns The instance of the current object for chaining. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/graphics-path.ts#L64-L70
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
GraphicsPath.ellipse
ellipse (x: number, y: number, radiusX: number, radiusY: number, transform?: Matrix4) { this.instructions.push({ action: 'ellipse', data: [x, y, radiusX, radiusY, transform] }); this.dirty = true; return this; }
/** * Draws an ellipse at the specified location and with the given x and y radii. * An optional transformation can be applied, allowing for rotation, scaling, and translation. * @param x - The x-coordinate of the center of the ellipse. * @param y - The y-coordinate of the center of the ellipse. * @param...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/graphics-path.ts#L82-L88
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
GraphicsPath.rect
rect (x: number, y: number, w: number, h: number, transform?: Matrix4): this { this.instructions.push({ action: 'rect', data: [x, y, w, h, transform] }); this.dirty = true; return this; }
/** * Draws a rectangle shape. This method adds a new rectangle path to the current drawing. * @param x - The x-coordinate of the upper-left corner of the rectangle. * @param y - The y-coordinate of the upper-left corner of the rectangle. * @param w - The width of the rectangle. * @param h - The height o...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/graphics-path.ts#L99-L105
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Point.constructor
constructor (x = 0, y = 0) { this.x = x; this.y = y; }
/** * Creates a new `Point` * @param {number} [x=0] - position of the point on the x axis * @param {number} [y=0] - position of the point on the y axis */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/point.ts#L23-L26
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Point.clone
clone (): Point { return new Point(this.x, this.y); }
/** * Creates a clone of this point * @returns A clone of this point */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/point.ts#L32-L34
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Point.copyFrom
copyFrom (p: PointData): this { this.set(p.x, p.y); return this; }
/** * Copies `x` and `y` from the given point into this point * @param p - The point to copy from * @returns The point instance itself */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/point.ts#L41-L45
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Point.copyTo
copyTo<T extends PointLike> (p: T): T { p.set(this.x, this.y); return p; }
/** * Copies this point's x and y into the given point (`p`). * @param p - The point to copy to. Can be any of type that is or extends `PointData` * @returns The point (`p`) with values updated */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/point.ts#L52-L56
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Point.equals
equals (p: PointData): boolean { return (p.x === this.x) && (p.y === this.y); }
/** * Accepts another point (`p`) and returns `true` if the given point is equal to this point * @param p - The point to check * @returns Returns `true` if both `x` and `y` are equal */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/point.ts#L63-L65
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Point.set
set (x = 0, y: number = x): this { this.x = x; this.y = y; return this; }
/** * Sets the point to a new `x` and `y` position. * If `y` is omitted, both `x` and `y` will be set to `x`. * @param {number} [x=0] - position of the point on the `x` axis * @param {number} [y=x] - position of the point on the `y` axis * @returns The point instance itself */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/point.ts#L74-L79
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Point.shared
static get shared (): Point { tempPoint.x = 0; tempPoint.y = 0; return tempPoint; }
/** * A static Point object with `x` and `y` values of `0`. Can be used to avoid creating new objects multiple times. * @readonly */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/point.ts#L85-L90
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
PolyStar.constructor
constructor ( public pointCount = 0, public outerRadius = 0, public innerRadius = 0, public outerRoundness = 0, public innerRoundness = 0, public starType = StarType.Star, ) { super(); }
/** * * @param pointCount - 多边形顶点数量 * @param outerRadius - 外半径大小 * @param innerRadius - 内半径大小 * @param outerRoundness - 外顶点圆滑度百分比 * @param innerRoundness - 内顶点圆滑度百分比 * @param starType - PolyStar 类型 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/poly-star.ts#L33-L42
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.constructor
constructor (...points: (PointData[] | number[])[] | PointData[] | number[]) { super(); let flat = Array.isArray(points[0]) ? points[0] : points; // if this is an array of points, convert it to a flat array of numbers if (typeof flat[0] !== 'number') { const p: number[] = []; for (let i = ...
/** * @param points - This can be an array of Points * that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or * the arguments passed can be all the points of the polygon e.g. * `new Polygon(new Point(), new Point(), ...)`, or the arguments passed can be flat * ...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L33-L50
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.clone
clone (): Polygon { const points = this.points.slice(); const polygon = new Polygon(points); polygon.closePath = this.closePath; return polygon; }
/** * Creates a clone of this polygon. * @returns - A copy of the polygon. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L56-L63
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.contains
contains (x: number, y: number): boolean { let inside = false; // use some raycasting to test hits // https://github.com/substack/point-in-polygon/blob/master/index.js const length = this.points.length / 2; for (let i = 0, j = length - 1; i < length; j = i++) { const xi = this.points[i * 2];...
/** * Checks whether the x and y coordinates passed to this function are contained within this polygon. * @param x - The X coordinate of the point to test. * @param y - The Y coordinate of the point to test. * @returns - Whether the x/y coordinates are within this polygon. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L71-L91
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.copyFrom
copyFrom (polygon: Polygon): this { this.points = polygon.points.slice(); this.closePath = polygon.closePath; return this; }
/** * Copies another polygon to this one. * @param polygon - The polygon to copy from. * @returns Returns itself. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L98-L103
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.copyTo
copyTo (polygon: Polygon): Polygon { polygon.copyFrom(this); return polygon; }
/** * Copies this polygon to another one. * @param polygon - The polygon to copy to. * @returns Returns given parameter. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L110-L114
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.lastX
get lastX (): number { return this.points[this.points.length - 2]; }
/** * Get the last X coordinate of the polygon * @readonly */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L120-L122
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.lastY
get lastY (): number { return this.points[this.points.length - 1]; }
/** * Get the last Y coordinate of the polygon * @readonly */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L128-L130
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.getX
getX (): number { return this.points[this.points.length - 2]; }
/** * Get the first X coordinate of the polygon * @readonly */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L136-L138
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Polygon.getY
getY (): number { return this.points[this.points.length - 1]; }
/** * Get the first Y coordinate of the polygon * @readonly */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/polygon.ts#L143-L145
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.constructor
constructor (x: string | number = 0, y: string | number = 0, width: string | number = 0, height: string | number = 0) { super(); this.x = Number(x); this.y = Number(y); this.width = Number(width); this.height = Number(height); }
/** * @param x - The X coordinate of the upper-left corner of the rectangle * @param y - The Y coordinate of the upper-left corner of the rectangle * @param width - The overall width of the rectangle * @param height - The overall height of the rectangle */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L40-L46
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.left
get left (): number { return this.x; }
/** Returns the left edge of the rectangle. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L49-L51
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.right
get right (): number { return this.x + this.width; }
/** Returns the right edge of the rectangle. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L54-L56
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.top
get top (): number { return this.y; }
/** Returns the top edge of the rectangle. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L59-L61
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.bottom
get bottom (): number { return this.y + this.height; }
/** Returns the bottom edge of the rectangle. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L64-L66
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.isEmpty
isEmpty (): boolean { return this.left === this.right || this.top === this.bottom; }
/** Determines whether the Rectangle is empty. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L69-L71
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.EMPTY
static get EMPTY (): Rectangle { return new Rectangle(0, 0, 0, 0); }
/** A constant empty rectangle. This is a new object every time the property is accessed */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L74-L76
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.clone
clone (): Rectangle { return new Rectangle(this.x, this.y, this.width, this.height); }
/** * Creates a clone of this Rectangle * @returns a copy of the rectangle */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L82-L84
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.copyFrom
copyFrom (rectangle: Rectangle): Rectangle { this.x = rectangle.x; this.y = rectangle.y; this.width = rectangle.width; this.height = rectangle.height; return this; }
/** * Copies another rectangle to this one. * @param rectangle - The rectangle to copy from. * @returns Returns itself. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L105-L112
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.copyTo
copyTo (rectangle: Rectangle): Rectangle { rectangle.copyFrom(this); return rectangle; }
/** * Copies this rectangle to another one. * @param rectangle - The rectangle to copy to. * @returns Returns given parameter. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L119-L123
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.contains
contains (x: number, y: number): boolean { if (this.width <= 0 || this.height <= 0) { return false; } if (x >= this.x && x < this.x + this.width) { if (y >= this.y && y < this.y + this.height) { return true; } } return false; }
/** * Checks whether the x and y coordinates given are contained within this Rectangle * @param x - The X coordinate of the point to test * @param y - The Y coordinate of the point to test * @returns Whether the x/y coordinates are within this Rectangle */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L131-L143
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.strokeContains
strokeContains (x: number, y: number, strokeWidth: number): boolean { const { width, height } = this; if (width <= 0 || height <= 0) { return false; } const _x = this.x; const _y = this.y; const outerLeft = _x - (strokeWidth / 2); const outerRight = _x + width + (strokeWidth / 2); const o...
/** * Checks whether the x and y coordinates given are contained within this rectangle including the stroke. * @param x - The X coordinate of the point to test * @param y - The Y coordinate of the point to test * @param strokeWidth - The width of the line to check * @returns Whether the x/y coordinates a...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L152-L171
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.pad
pad (paddingX = 0, paddingY = paddingX): this { this.x -= paddingX; this.y -= paddingY; this.width += paddingX * 2; this.height += paddingY * 2; return this; }
/** * Pads the rectangle making it grow in all directions. * If paddingY is omitted, both paddingX and paddingY will be set to paddingX. * @param paddingX - The horizontal padding amount. * @param paddingY - The vertical padding amount. * @returns Returns itself. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L266-L274
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.fit
fit (rectangle: Rectangle): this { const x1 = Math.max(this.x, rectangle.x); const x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width); const y1 = Math.max(this.y, rectangle.y); const y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height); this.x = x1; this.width = Ma...
/** * Fits this rectangle around the passed one. * @param rectangle - The rectangle to fit. * @returns Returns itself. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L281-L293
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.ceil
ceil (resolution = 1, eps = 0.001): this { const x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution; const y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution; this.x = Math.floor((this.x + eps) * resolution) / resolution; this.y = Math.floor((this.y + eps) * resol...
/** * Enlarges rectangle that way its corners lie on grid * @param resolution - resolution * @param eps - precision * @returns Returns itself. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L301-L312
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.enlarge
enlarge (rectangle: Rectangle): this { const x1 = Math.min(this.x, rectangle.x); const x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width); const y1 = Math.min(this.y, rectangle.y); const y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height); this.x = x1; this.width ...
/** * Enlarges this rectangle to include the passed rectangle. * @param rectangle - The rectangle to include. * @returns Returns itself. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L319-L331
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Rectangle.getBounds
getBounds (out?: Rectangle): Rectangle { out = out || new Rectangle(); out.copyFrom(this); return out; }
/** * Returns the framing rectangle of the rectangle as a Rectangle object * @param out - optional rectangle to store the result * @returns The framing rectangle */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/rectangle.ts#L338-L343
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShapePath.buildPath
buildPath () { this.currentPoly = null; this.shapePrimitives.length = 0; const path = this.graphicsPath; for (const instruction of path.instructions) { const action = instruction.action; const data = instruction.data; switch (action) { case 'bezierCurveTo': { this.b...
/** Builds the path. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/shape-path.ts#L25-L63
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShapePath.bezierCurveTo
bezierCurveTo ( cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number, smoothness?: number, ): ShapePath { this.ensurePoly(); const currentPoly = this.currentPoly as Polygon; buildAdaptiveBezier( currentPoly.points, currentPoly.lastX, currentPoly.lastY, ...
/** * Adds a cubic Bezier curve to the path. * It requires three points: the first two are control points and the third one is the end point. * The starting point is the last point in the current path. * @param cp1x - The x-coordinate of the first control point. * @param cp1y - The y-coordinate of the fi...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/shape-path.ts#L78-L94
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShapePath.ellipse
ellipse (x: number, y: number, radiusX: number, radiusY: number, transform?: Matrix4): this { // TODO apply rotation to transform... this.drawShape(new Ellipse(x, y, radiusX, radiusY), transform); return this; }
/** * Draws an ellipse at the specified location and with the given x and y radii. * An optional transformation can be applied, allowing for rotation, scaling, and translation. * @param x - The x-coordinate of the center of the ellipse. * @param y - The y-coordinate of the center of the ellipse. * @param...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/shape-path.ts#L112-L118
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShapePath.rect
rect (x: number, y: number, w: number, h: number, transform?: Matrix4): this { this.drawShape(new Rectangle(x, y, w, h), transform); return this; }
/** * Draws a rectangle shape. This method adds a new rectangle path to the current drawing. * @param x - The x-coordinate of the upper-left corner of the rectangle. * @param y - The y-coordinate of the upper-left corner of the rectangle. * @param w - The width of the rectangle. * @param h - The height o...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/shape-path.ts#L135-L139
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShapePath.drawShape
drawShape (shape: ShapePrimitive, matrix?: Matrix4): this { this.endPoly(); this.shapePrimitives.push({ shape, transform: matrix }); return this; }
/** * Draws a given shape on the canvas. * This is a generic method that can draw any type of shape specified by the `ShapePrimitive` parameter. * An optional transformation matrix can be applied to the shape, allowing for complex transformations. * @param shape - The shape to draw, defined as a `ShapePrimi...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/shape-path.ts#L150-L156
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShapePath.startPoly
private startPoly (x: number, y: number): this { let currentPoly = this.currentPoly; if (currentPoly) { this.endPoly(); } currentPoly = new Polygon(); currentPoly.points.push(x, y); this.currentPoly = currentPoly; return this; }
/** * Starts a new polygon path from the specified starting point. * This method initializes a new polygon or ends the current one if it exists. * @param x - The x-coordinate of the starting point of the new polygon. * @param y - The y-coordinate of the starting point of the new polygon. * @returns The i...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/shape-path.ts#L165-L179
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShapePath.endPoly
private endPoly (closePath = false): this { const shape = this.currentPoly; if (shape && shape.points.length > 2) { shape.closePath = closePath; this.shapePrimitives.push({ shape }); } this.currentPoly = null; return this; }
/** * Ends the current polygon path. If `closePath` is set to true, * the path is closed by connecting the last point to the first one. * This method finalizes the current polygon and prepares it for drawing or adding to the shape primitives. * @param closePath - A boolean indicating whether to close the po...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/shape-path.ts#L189-L201
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Triangle.constructor
constructor (x = 0, y = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0) { super(); this.x = x; this.y = y; this.x2 = x2; this.y2 = y2; this.x3 = x3; this.y3 = y3; }
/** * @param x - The X coord of the first point. * @param y - The Y coord of the first point. * @param x2 - The X coord of the second point. * @param y2 - The Y coord of the second point. * @param x3 - The X coord of the third point. * @param y3 - The Y coord of the third point. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/triangle.ts#L49-L57
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Triangle.contains
contains (x: number, y: number): boolean { const s = ((this.x - this.x3) * (y - this.y3)) - ((this.y - this.y3) * (x - this.x3)); const t = ((this.x2 - this.x) * (y - this.y)) - ((this.y2 - this.y) * (x - this.x)); if ((s < 0) !== (t < 0) && s !== 0 && t !== 0) { return false; } const d = ((this.x3 - ...
/** * Checks whether the x and y coordinates given are contained within this triangle * @param x - The X coordinate of the point to test * @param y - The Y coordinate of the point to test * @returns Whether the x/y coordinates are within this Triangle */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/triangle.ts#L65-L74
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Triangle.clone
clone (): ShapePrimitive { const triangle = new Triangle( this.x, this.y, this.x2, this.y2, this.x3, this.y3 ); return triangle; }
/** * Creates a clone of this Triangle * @returns a copy of the triangle */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/triangle.ts#L102-L113
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Triangle.copyFrom
copyFrom (triangle: Triangle): this { this.x = triangle.x; this.y = triangle.y; this.x2 = triangle.x2; this.y2 = triangle.y2; this.x3 = triangle.x3; this.y3 = triangle.y3; return this; }
/** * Copies another triangle to this one. * @param triangle - The triangle to copy from. * @returns Returns itself. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/triangle.ts#L120-L129
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Triangle.copyTo
copyTo (triangle: Triangle): Triangle { triangle.copyFrom(this); return triangle; }
/** * Copies this triangle to another one. * @param triangle - The triangle to copy to. * @returns Returns given parameter. */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/triangle.ts#L136-L140
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Triangle.getBounds
getBounds (out?: Rectangle): Rectangle { out = out || new Rectangle(); const minX = Math.min(this.x, this.x2, this.x3); const maxX = Math.max(this.x, this.x2, this.x3); const minY = Math.min(this.y, this.y2, this.y3); const maxY = Math.max(this.y, this.y2, this.y3); out.x = minX; out.y = m...
/** * Returns the framing rectangle of the triangle as a Rectangle object * @param out - optional rectangle to store the result * @returns The framing rectangle */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/triangle.ts#L147-L161
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
vertexCallback
function vertexCallback ( data: [x: number, y: number, z: number], polyVertArray: number[], ) { polyVertArray[polyVertArray.length] = data[0]; polyVertArray[polyVertArray.length] = data[1]; }
// function called for each vertex of tesselator output
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/triangulate.ts#L5-L11
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
combinecallback
function combinecallback ( coords: [number, number, number], data: number[][], weight: number[], ) { // console.log('combine callback'); return [coords[0], coords[1], coords[2]]; }
// callback for when segments intersect and must be split
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/shape/triangulate.ts#L21-L28
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpriteComponent.constructor
constructor (engine: Engine, props?: SpriteItemProps) { super(engine); this.name = 'MSprite' + seed++; this.geometry = this.createGeometry(glContext.TRIANGLES); this.setItem(); if (props) { this.fromData(props); } }
// override opacityOverLifetime: ValueGetter<number>;
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/sprite/sprite-item.ts#L69-L78
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TextComponentBase.setFontSize
setFontSize (value: number): void { if (this.textStyle.fontSize === value) { return; } // 保证字号变化后位置正常 const diff = this.textStyle.fontSize - value; this.textLayout.lineHeight += diff; this.textStyle.fontSize = value; this.isDirty = true; }
/** * 设置字号大小 * @param value - 字号 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/text/text-item.ts#L207-L218
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TextComponentBase.setFontWeight
setFontWeight (value: spec.TextWeight): void { if (this.textStyle.textWeight === value) { return; } this.textStyle.textWeight = value; this.isDirty = true; }
/** * 设置字重 * @param value - 字重类型 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/text/text-item.ts#L225-L231
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TextComponentBase.setFontStyle
setFontStyle (value: spec.FontStyle): void { if (this.textStyle.fontStyle === value) { return; } this.textStyle.fontStyle = value; this.isDirty = true; }
/** * 设置字体类型 * @param value 字体类型 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/text/text-item.ts#L238-L244
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TextComponentBase.setText
setText (value: string): void { if (this.text === value) { return; } this.text = value.toString(); this.lineCount = this.getLineCount(value, false); this.isDirty = true; }
/** * 设置文本 * @param value - 文本内容 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/text/text-item.ts#L251-L258
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TextComponentBase.setTextAlign
setTextAlign (value: spec.TextAlignment): void { if (this.textLayout.textAlign === value) { return; } this.textLayout.textAlign = value; this.isDirty = true; }
/** * 设置文本水平布局 * @param value - 布局选项 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/plugins/text/text-item.ts#L265-L271
20512f4406e62c400b2b4255576cfa628db74a22