MCPcopy Create free account
hub / github.com/esengine/esengine / centerOn

Method centerOn

packages/fairygui/src/widgets/Window.ts:257–267  ·  view source on GitHub ↗

* Center window on GRoot * 在 GRoot 上居中窗口

(r: GRoot, bRestraint?: boolean)

Source from the content-addressed store, hash-verified

255 * 在 GRoot 上居中窗口
256 */
257 public centerOn(r: GRoot, bRestraint?: boolean): void {
258 this.setXY(
259 Math.round((r.width - this.width) / 2),
260 Math.round((r.height - this.height) / 2)
261 );
262
263 if (bRestraint) {
264 this.relations.add(r, ERelationType.CenterCenter);
265 this.relations.add(r, ERelationType.MiddleMiddle);
266 }
267 }
268
269 /**
270 * Toggle window visibility

Callers

nothing calls this directly

Calls 2

setXYMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected