package d2graphimportconst (// MaxGridDimension bounds each axis of an explicitly dimensioned grid. In // addition to layout work, this limits the coordinate span contributed by // empty cells before output-specific resource limits run.MaxGridDimension = 10_000// MaxGridCells bounds the capacity of an explicitly dimensioned grid. Grid // layout retains empty cells so that diagrams can add objects in later boards, // which makes rows*columns the relevant amount of user-controlled work even // when the current board contains few objects.MaxGridCells = 1_000_000)// GridCapacity returns rows*columns when both axes and their product are// bounded. The division check keeps the multiplication from overflowing an int.func (, int) (int, error) {if <= 0 || <= 0 {return0, fmt.Errorf("grid dimensions must be positive, got %d by %d", , ) }if > MaxGridDimension || > MaxGridDimension {return0, fmt.Errorf("grid dimensions %d by %d exceed the maximum of %d rows or columns", , , MaxGridDimension) }if > MaxGridCells/ {return0, fmt.Errorf("grid dimensions %d by %d exceed the limit of %d cells", , , MaxGridCells) }return * , nil}func ( *Object) () bool {return != nil && (.GridRows != nil || .GridColumns != nil)}func ( *Object) () *Object {if == nil {returnnil }if .IsGridDiagram() {return }return .Parent.()}func ( *Object) () *Object {if == nil {returnnil }// grid cells can be a nested grid diagramif .Parent.IsGridDiagram() {return }return .Parent.()}// TopGridDiagram returns the least nested (outermost) grid diagramfunc ( *Object) () *Object {if == nil {returnnil }var *Objectif .IsGridDiagram() { = } := .Parentfor != nil {if .IsGridDiagram() { = } = .Parent }return}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.