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

Method center

packages/fairygui/src/core/GObject.ts:210–219  ·  view source on GitHub ↗

* Center this object in its parent * 在父容器中居中

(bRestraint: boolean = false)

Source from the content-addressed store, hash-verified

208 * 在父容器中居中
209 */
210 public center(bRestraint: boolean = false): void {
211 const r = this._parent || this.root;
212 if (r) {
213 this.setXY((r.width - this.width) / 2, (r.height - this.height) / 2);
214 if (bRestraint) {
215 this.addRelation(r, ERelationType.CenterCenter);
216 this.addRelation(r, ERelationType.MiddleMiddle);
217 }
218 }
219 }
220
221 // Size | 尺寸
222

Callers

nothing calls this directly

Calls 2

setXYMethod · 0.95
addRelationMethod · 0.95

Tested by

no test coverage detected