本文整理汇总了Golang中github.com/skelterjohn/geom.Rect.Width方法的典型用法代码示例。如果您正苦于以下问题:Golang Rect.Width方法的具体用法?Golang Rect.Width怎么用?Golang Rect.Width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skelterjohn/geom.Rect
的用法示例。
在下文中一共展示了Rect.Width方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Remove
func (rs *RectangleStore) Remove(box *geom.Rect, coord *geom.Coord, i interface{}) error {
x := coord.X
y := coord.Y
xPrime := x + box.Width()
yPrime := y + box.Height()
startX := int(x) / rs.Width
endX := int(xPrime) / rs.Width
startY := int(y) / rs.Height
endY := int(yPrime) / rs.Height
for ii := startX; ii < endX; ii++ {
for jj := startY; jj < endY; jj++ {
if ii < 0 || jj < 0 || ii > len(rs.Values) || jj > len(rs.Values[0]) {
continue
}
for kk, toDel := range rs.Values[ii][jj] {
if toDel == i {
fmt.Println("removed")
copy(rs.Values[ii][jj][kk:], rs.Values[ii][jj][kk+1:])
rs.Values[ii][jj] = rs.Values[ii][jj][:len(rs.Values[ii][jj])-1]
}
}
}
}
return nil
}
示例2: NewRectangleStore
func NewRectangleStore(box *geom.Rect, innerBox *geom.Rect) *RectangleStore {
outerWidth := box.Width()
outerHeight := box.Height()
innerWidth := innerBox.Width()
innerHeight := innerBox.Height()
x := math.Floor(outerWidth / innerWidth)
y := math.Floor(outerHeight / innerHeight)
rs := &RectangleStore{
Values: make([][][]interface{}, int(x)),
Width: int(innerWidth),
Height: int(innerHeight),
}
for ii, _ := range rs.Values {
rs.Values[ii] = make([][]interface{}, int(y))
for jj, _ := range rs.Values[ii] {
rs.Values[ii][jj] = make([]interface{}, InitialSize)
}
}
fmt.Printf("rectangles: %+v, %+v \n", len(rs.Values), len(rs.Values[0]))
fmt.Printf("box: %v\n", box)
fmt.Printf("inbox: %v\n", innerBox)
return rs
}
示例3: Add
func (rs *RectangleStore) Add(box *geom.Rect, coord *geom.Coord, i interface{}) error {
x := coord.X
y := coord.Y
xPrime := x + box.Width()
yPrime := y + box.Height()
fmt.Println(x, y)
fmt.Println(xPrime, yPrime)
startX := int(x) / rs.Width
endX := int(xPrime) / rs.Width
startY := int(y) / rs.Height
endY := int(yPrime) / rs.Height
for ii := startX; ii <= endX; ii++ {
for jj := startY; jj <= endY; jj++ {
if ii < 0 || jj < 0 || ii >= len(rs.Values) || jj >= len(rs.Values[0]) {
continue
}
// fmt.Printf("%v, %v :: %v, %v\n", ii, jj, len(rs.Values), len(rs.Values[ii]))
rs.Values[ii][jj] = append(rs.Values[ii][jj], i)
}
}
return nil
}
示例4: Inside
func (rs *RectangleStore) Inside(box *geom.Rect, coord *geom.Coord) []interface{} {
var i []interface{}
x := coord.X
y := coord.Y
xPrime := x + box.Width()
yPrime := y + box.Height()
startX := int(x) / rs.Width
endX := int(xPrime) / rs.Width
startY := int(y) / rs.Height
endY := int(yPrime) / rs.Height
dupMap := make(map[interface{}]bool)
for ii := startX; ii <= endX; ii++ {
for jj := startY; jj < endY; jj++ {
//fmt.Printf("Index %v, %v\n", ii, jj)
if ii < 0 || jj < 0 || ii >= len(rs.Values) || jj >= len(rs.Values[0]) {
continue
}
for _, val := range rs.Values[ii][jj] {
if val != nil && !dupMap[val] {
dupMap[val] = true
i = append(i, val)
}
}
}
}
return i
}
示例5: IsBig
func (me *Tree) IsBig(bounds geom.Rect) bool {
return bounds.Width() >= me.cfg.SplitSizeRatio*me.UpperBounds.Width() ||
bounds.Height() >= me.cfg.SplitSizeRatio*me.UpperBounds.Height()
}