forked from tdewolff/canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
121 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
package layout | ||
|
||
import "math" | ||
|
||
type Size struct { | ||
MinWidth, MaxWidth float64 | ||
MinHeight, MaxHeight float64 | ||
} | ||
|
||
func newSize() Size { | ||
return Size{ | ||
MinWidth: 0.0, | ||
MaxWidth: math.Inf(1.0), | ||
MinHeight: 0.0, | ||
MaxHeight: math.Inf(1.0), | ||
} | ||
} | ||
|
||
type Item interface { | ||
Size() Size | ||
} | ||
|
||
type Layout struct { | ||
items []Item | ||
} | ||
|
||
func (l *Layout) Size() Size { | ||
size := newSize() | ||
for _, item := range l.items { | ||
isize := item.Size() | ||
size.MinWidth = math.Max(size.MinWidth, isize.MinWidth) | ||
size.MaxWidth = math.Min(size.MaxWidth, isize.MaxWidth) | ||
size.MinHeight += isize.MinHeight | ||
size.MaxHeight += isize.MaxHeight | ||
} | ||
return size | ||
} | ||
//import "math" | ||
// | ||
//type Size struct { | ||
// MinWidth, MaxWidth float64 | ||
// MinHeight, MaxHeight float64 | ||
//} | ||
// | ||
//func newSize() Size { | ||
// return Size{ | ||
// MinWidth: 0.0, | ||
// MaxWidth: math.Inf(1.0), | ||
// MinHeight: 0.0, | ||
// MaxHeight: math.Inf(1.0), | ||
// } | ||
//} | ||
// | ||
//type Item interface { | ||
// Size() Size | ||
//} | ||
// | ||
//type Layout struct { | ||
// items []Item | ||
//} | ||
// | ||
//func (l *Layout) Size() Size { | ||
// size := newSize() | ||
// for _, item := range l.items { | ||
// isize := item.Size() | ||
// size.MinWidth = math.Max(size.MinWidth, isize.MinWidth) | ||
// size.MaxWidth = math.Min(size.MaxWidth, isize.MaxWidth) | ||
// size.MinHeight += isize.MinHeight | ||
// size.MaxHeight += isize.MaxHeight | ||
// } | ||
// return size | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.