• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang geom.Rect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/skelterjohn/geom.Rect的典型用法代码示例。如果您正苦于以下问题:Golang Rect类的具体用法?Golang Rect怎么用?Golang Rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Rect类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: NewImage

func NewImage(path string) (*Image, error) {
	f, ferr := os.Open(path)
	if ferr != nil {
		fmt.Fprintf(os.Stderr, "%v\n", ferr)

		return nil, fmt.Errorf("Could not open image %v", ferr)
	}
	defer f.Close()
	imConf, _, err := image.DecodeConfig(f)
	if err != nil {
		return nil, fmt.Errorf("Could not decode image", err)
	}

	im := Image{}
	im.Path = path
	pathArr := strings.Split(path, "/")
	im.Url = "/inc/" + pathArr[len(pathArr)-1]
	fmt.Println(im.Url)
	size := geom.Rect{}
	size.Min = geom.Coord{X: 0, Y: 0}
	size.Max = geom.Coord{X: float64(imConf.Width), Y: float64(imConf.Height)}
	im.Size = size

	return &im, nil
}
开发者ID:jono-macd,项目名称:playjunk,代码行数:25,代码来源:image.go


示例2: 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
}
开发者ID:jono-macd,项目名称:playjunk,代码行数:32,代码来源:rectanglestore.go


示例3: RemoveInside

func (me *Tree) RemoveInside(bounds geom.Rect, collection map[Item]bool) {
	if !geom.RectsIntersect(bounds, me.UpperBounds) {
		return
	}
	if me.BigElements != nil {
		for elem := range me.BigElements {
			if bounds.ContainsRect(elem.Bounds()) {
				delete(me.BigElements, elem)
				if collection != nil {
					collection[elem] = true
				}
			}
		}
	}
	if me.Elements != nil {
		for elem := range me.Elements {
			if bounds.ContainsRect(elem.Bounds()) {
				delete(me.Elements, elem)
				if collection != nil {
					collection[elem] = true
				}
			}
		}
	}

	for _, t := range me.Subtrees {
		if t == nil {
			continue
		}
		t.RemoveInside(bounds, collection)
	}

	return
}
开发者ID:Nightgunner5,项目名称:geom,代码行数:34,代码来源:qtree.go


示例4: 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
}
开发者ID:jono-macd,项目名称:playjunk,代码行数:29,代码来源:rectanglestore.go


示例5: 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
}
开发者ID:jono-macd,项目名称:playjunk,代码行数:31,代码来源:rectanglestore.go


示例6: ConstructCells

func (self *Image) ConstructCells(number int, max geom.Coord) (err error) {

	size := geom.Rect{}
	size.Min = geom.Coord{X: 0, Y: 0}
	size.Max = max
	self.CellNumber = number
	self.CellSize = size
	return
}
开发者ID:jono-macd,项目名称:playjunk,代码行数:9,代码来源:image.go


示例7: 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
}
开发者ID:jono-macd,项目名称:playjunk,代码行数:28,代码来源:rectanglestore.go


示例8: 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()
}
开发者ID:Nightgunner5,项目名称:geom,代码行数:4,代码来源:qtree.go


示例9: regrid

func (g *Grid) regrid() {

	g.reflex()

	_, minXs, maxXs := g.hflex.constrain(g.Size.X)
	_, minYs, maxYs := g.vflex.constrain(g.Size.Y)

	for child, csh := range g.ChildrenHints {
		bd := g.childrenBlockData[child]
		gridBounds := geom.Rect{
			Min: geom.Coord{
				X: minXs[bd.GridX],
				Y: minYs[bd.GridY],
			},
			Max: geom.Coord{
				X: maxXs[bd.GridX+bd.ExtraX],
				Y: maxYs[bd.GridY+bd.ExtraY],
			},
		}

		gridSizeX, gridSizeY := gridBounds.Size()
		if gridSizeX > csh.MaxSize.X {
			diff := gridSizeX - csh.MaxSize.X
			if bd.AnchorX&AnchorMin != 0 && bd.AnchorX&AnchorMax != 0 {
				gridBounds.Min.X += diff / 2
				gridBounds.Max.X -= diff / 2
			} else if bd.AnchorX&AnchorMin != 0 {
				gridBounds.Max.X -= diff
			} else if bd.AnchorX&AnchorMax != 0 {
				gridBounds.Min.X += diff
			}
		}
		if gridSizeY > csh.MaxSize.Y {
			diff := gridSizeY - csh.MaxSize.Y
			if bd.AnchorY&AnchorMin == 0 && bd.AnchorY&AnchorMax == 0 {
				gridBounds.Min.Y += diff / 2
				gridBounds.Max.Y -= diff / 2
			} else if bd.AnchorY&AnchorMin != 0 {
				gridBounds.Max.Y -= diff
			} else if bd.AnchorY&AnchorMax != 0 {
				gridBounds.Min.Y += diff
			}
		}

		gridSizeX, gridSizeY = gridBounds.Size()
		if gridSizeX > csh.PreferredSize.X {
			diff := gridSizeX - csh.PreferredSize.X
			if bd.AnchorX&AnchorMin != 0 && bd.AnchorX&AnchorMax != 0 {
				gridBounds.Min.X += diff / 2
				gridBounds.Max.X -= diff / 2
			} else if bd.AnchorX&AnchorMin != 0 {
				gridBounds.Max.X -= diff
			} else if bd.AnchorX&AnchorMax != 0 {
				gridBounds.Min.X += diff
			}
		}
		if gridSizeY > csh.PreferredSize.Y {
			diff := gridSizeY - csh.PreferredSize.Y
			if bd.AnchorY&AnchorMin == 0 && bd.AnchorY&AnchorMax == 0 {
				gridBounds.Min.Y += diff / 2
				gridBounds.Max.Y -= diff / 2
			} else if bd.AnchorY&AnchorMin != 0 {
				gridBounds.Max.Y -= diff
			} else if bd.AnchorY&AnchorMax != 0 {
				gridBounds.Min.Y += diff
			}
		}

		g.ChildrenBounds[child] = gridBounds

		gridSizeX, gridSizeY = gridBounds.Size()
		child.UserEventsIn <- uik.ResizeEvent{
			Size: geom.Coord{gridSizeX, gridSizeY},
		}
	}

	g.Invalidate()
}
开发者ID:KarateCode,项目名称:go.uik,代码行数:78,代码来源:grid.go


示例10: GetLayout

func (g *GridEngine) GetLayout(size geom.Coord) (layout Layout) {

	layout = make(Layout)

	_, minXs, maxXs := g.hflex.constrain(size.X)
	_, minYs, maxYs := g.vflex.constrain(size.Y)

	// if g.Block.ID == 2 {
	// 	uik.Report("regrid", g.Block.ID, g.Size, whs, wvs)
	// }

	for child, csh := range g.childrenHints {
		bd := g.childrenGridComponents[child]
		gridBounds := geom.Rect{
			Min: geom.Coord{
				X: minXs[bd.GridX],
				Y: minYs[bd.GridY],
			},
			Max: geom.Coord{
				X: maxXs[bd.GridX+bd.ExtraX],
				Y: maxYs[bd.GridY+bd.ExtraY],
			},
		}

		gridSizeX, gridSizeY := gridBounds.Size()
		if gridSizeX > csh.MaxSize.X {
			diff := gridSizeX - csh.MaxSize.X
			if !bd.AnchorLeft && !bd.AnchorRight {
				gridBounds.Min.X += diff / 2
				gridBounds.Max.X -= diff / 2
			}
			if bd.AnchorLeft && !bd.AnchorRight {
				gridBounds.Max.X -= diff
			}
			if !bd.AnchorLeft && bd.AnchorRight {
				gridBounds.Min.X += diff
			}
		}
		if gridSizeY > csh.MaxSize.Y {
			diff := gridSizeY - csh.MaxSize.Y
			if !bd.AnchorTop && !bd.AnchorBottom {
				gridBounds.Min.Y += diff / 2
				gridBounds.Max.Y -= diff / 2
			}
			if bd.AnchorTop && !bd.AnchorBottom {
				gridBounds.Max.Y -= diff
			}
			if !bd.AnchorTop && bd.AnchorBottom {
				gridBounds.Min.Y += diff
			}
		}

		gridSizeX, gridSizeY = gridBounds.Size()
		if gridSizeX > csh.PreferredSize.X {
			diff := gridSizeX - csh.PreferredSize.X
			if !bd.AnchorLeft && !bd.AnchorRight {
				gridBounds.Min.X += diff / 2
				gridBounds.Max.X -= diff / 2
			}
			if bd.AnchorLeft && !bd.AnchorRight {
				gridBounds.Max.X -= diff
			}
			if !bd.AnchorLeft && bd.AnchorRight {
				gridBounds.Min.X += diff
			}
		}
		if gridSizeY > csh.PreferredSize.Y {
			diff := gridSizeY - csh.PreferredSize.Y
			if !bd.AnchorTop && !bd.AnchorBottom {
				gridBounds.Min.Y += diff / 2
				gridBounds.Max.Y -= diff / 2
			}
			if bd.AnchorTop && !bd.AnchorBottom {
				gridBounds.Max.Y -= diff
			}
			if !bd.AnchorTop && bd.AnchorBottom {
				gridBounds.Min.Y += diff
			}
		}

		layout[child] = gridBounds

	}

	return
}
开发者ID:skelterjohn,项目名称:go.uik,代码行数:86,代码来源:grid.go



注:本文中的github.com/skelterjohn/geom.Rect类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang matrix.DenseMatrix类代码示例发布时间:2022-05-28
下一篇:
Golang commands_util.SplitParamValues函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap