本文整理匯總了Golang中github.com/google/gxui/math.Point.Sub方法的典型用法代碼示例。如果您正苦於以下問題:Golang Point.Sub方法的具體用法?Golang Point.Sub怎麽用?Golang Point.Sub使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/gxui/math.Point
的用法示例。
在下文中一共展示了Point.Sub方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PixelAt
func (i *Image) PixelAt(p math.Point) (math.Point, bool) {
ir := i.calculateDrawRect()
if tex := i.Texture(); tex != nil {
s := tex.SizePixels()
p = p.Sub(ir.Min).
ScaleX(float32(s.W) / float32(ir.W())).
ScaleY(float32(s.H) / float32(ir.H()))
if s.Rect().Contains(p) {
return p, true
}
}
return math.Point{X: -1, Y: -1}, false
}
示例2: draw
func draw(p Pendulum, canvas gxui.Canvas, x, y int) {
attachment := math.Point{X: ANIMATION_WIDTH/2 + x, Y: y}
phi := p.GetPhi()
ball := math.Point{X: x + ANIMATION_WIDTH/2 + math.Round(float32(l*omath.Sin(phi))), Y: y + math.Round(float32(l*omath.Cos(phi)))}
line := gxui.Polygon{gxui.PolygonVertex{attachment, 0}, gxui.PolygonVertex{ball, 0}}
canvas.DrawLines(line, gxui.DefaultPen)
m := math.Point{int(BALL_RADIUS), int(BALL_RADIUS)}
rect := math.Rect{ball.Sub(m), ball.Add(m)}
canvas.DrawRoundedRect(rect, BALL_RADIUS, BALL_RADIUS, BALL_RADIUS, BALL_RADIUS, gxui.TransparentPen, gxui.CreateBrush(gxui.Yellow))
}
示例3: ContainsPoint
func (c *Container) ContainsPoint(p math.Point) bool {
if !c.outer.IsVisible() || !c.outer.Size().Rect().Contains(p) {
return false
}
for _, v := range c.children {
if v.Control.ContainsPoint(p.Sub(v.Offset)) {
return true
}
}
if c.IsMouseEventTarget() {
return true
}
return false
}
示例4: TopControlsUnder
func TopControlsUnder(p math.Point, c Parent) ControlPointList {
children := c.Children()
for i := len(children) - 1; i >= 0; i-- {
child := children[i]
cp := p.Sub(child.Offset)
if child.Control.ContainsPoint(cp) {
l := ControlPointList{ControlPoint{child.Control, cp}}
if cc, ok := child.Control.(Parent); ok {
l = append(l, TopControlsUnder(cp, cc)...)
}
return l
}
}
return ControlPointList{}
}
示例5: BreadcrumbsAt
func BreadcrumbsAt(p Container, pnt math.Point) string {
s := reflect.TypeOf(p).String()
for _, c := range p.Children() {
b := c.Control.Size().Rect().Offset(c.Offset)
if b.Contains(pnt) {
switch t := c.Control.(type) {
case Container:
return s + " > " + BreadcrumbsAt(t, pnt.Sub(c.Offset))
default:
return s + " > " + reflect.TypeOf(c.Control).String()
}
}
}
return s
}
示例6: ControlsUnder
func ControlsUnder(p math.Point, c Parent) ControlPointList {
toVisit := []ParentPoint{ParentPoint{c, p}}
l := ControlPointList{}
for len(toVisit) > 0 {
c = toVisit[0].C
p = toVisit[0].P
toVisit = toVisit[1:]
for _, child := range c.Children() {
cp := p.Sub(child.Offset)
if child.Control.ContainsPoint(cp) {
l = append(l, ControlPoint{child.Control, cp})
if cc, ok := child.Control.(Parent); ok {
toVisit = append(toVisit, ParentPoint{cc, cp})
}
}
}
}
return l
}
示例7: WindowToChild
func WindowToChild(coord math.Point, to Control) math.Point {
c := to
for {
p := c.Parent()
if p == nil {
panic("Control's parent was nil")
}
child := p.Children().Find(c)
if child == nil {
Dump(p)
panic(fmt.Errorf("Control's parent (%p %T) did not contain control (%p %T).", &p, p, &c, c))
}
coord = coord.Sub(child.Offset)
if _, ok := p.(Window); ok {
return coord
}
c = p.(Control)
}
}
示例8: ParentToChild
func ParentToChild(coord math.Point, from Parent, to Control) math.Point {
return coord.Sub(ChildToParent(math.ZeroPoint, to, from))
}