d2/d2graph/grid.go
2023-04-04 18:45:08 -07:00

16 lines
333 B
Go

package d2graph
func (obj *Object) IsGrid() bool {
return obj != nil && obj.Attributes != nil &&
(obj.Attributes.Rows != nil || obj.Attributes.Columns != nil)
}
func (obj *Object) ClosestGrid() *Object {
if obj.Parent == nil {
return nil
}
if obj.Parent.IsGrid() {
return obj.Parent
}
return obj.Parent.ClosestGrid()
}