2023-04-01 00:18:17 +00:00
|
|
|
package d2graph
|
|
|
|
|
|
|
|
|
|
func (obj *Object) IsGrid() bool {
|
2023-04-04 04:38:08 +00:00
|
|
|
return obj != nil && obj.Attributes != nil &&
|
2023-04-01 00:18:17 +00:00
|
|
|
(obj.Attributes.Rows != nil || obj.Attributes.Columns != nil)
|
|
|
|
|
}
|
2023-04-05 00:44:05 +00:00
|
|
|
|
|
|
|
|
func (obj *Object) ClosestGrid() *Object {
|
|
|
|
|
if obj.Parent == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
if obj.Parent.IsGrid() {
|
|
|
|
|
return obj.Parent
|
|
|
|
|
}
|
|
|
|
|
return obj.Parent.ClosestGrid()
|
|
|
|
|
}
|