d2/d2graph/grid.go

17 lines
333 B
Go
Raw Normal View History

2023-04-01 00:18:17 +00:00
package d2graph
func (obj *Object) IsGrid() bool {
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()
}