本文整理匯總了Golang中github.com/google/gxui/math.Point.Y方法的典型用法代碼示例。如果您正苦於以下問題:Golang Point.Y方法的具體用法?Golang Point.Y怎麽用?Golang Point.Y使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/gxui/math.Point
的用法示例。
在下文中一共展示了Point.Y方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: change
func change(point *math.Point, direction string) {
switch direction {
case Top:
point.Y -= 20
case Right:
point.X += 20
case Bottom:
point.Y += 20
case Left:
point.X -= 20
}
}
示例2: align
func (f *font) align(rect math.Rect, size math.Size, ascent int, h gxui.HorizontalAlignment, v gxui.VerticalAlignment) math.Point {
var origin math.Point
switch h {
case gxui.AlignLeft:
origin.X = rect.Min.X
case gxui.AlignCenter:
origin.X = rect.Mid().X - (size.W / 2)
case gxui.AlignRight:
origin.X = rect.Max.X - size.W
}
switch v {
case gxui.AlignTop:
origin.Y = rect.Min.Y + ascent
case gxui.AlignMiddle:
origin.Y = rect.Mid().Y - (size.H / 2) + ascent
case gxui.AlignBottom:
origin.Y = rect.Max.Y - size.H + ascent
}
return origin
}
示例3: Measure
func (f *font) Measure(fl *gxui.TextBlock) math.Size {
size := math.Size{W: 0, H: f.glyphMaxSizeDips.H}
var offset math.Point
for _, r := range fl.Runes {
if r == '\n' {
offset.X = 0
offset.Y += f.glyphMaxSizeDips.H
continue
}
offset.X += f.advanceDips(r)
size = size.Max(math.Size{W: offset.X, H: offset.Y + f.glyphMaxSizeDips.H})
}
return size
}
示例4: Layout
func (f *font) Layout(fl *gxui.TextBlock) (offsets []math.Point) {
sizeDips := math.Size{}
offsets = make([]math.Point, len(fl.Runes))
var offset math.Point
for i, r := range fl.Runes {
if r == '\n' {
offset.X = 0
offset.Y += f.glyphMaxSizeDips.H
continue
}
offsets[i] = offset
offset.X += f.advanceDips(r)
sizeDips = sizeDips.Max(math.Size{W: offset.X, H: offset.Y + f.glyphMaxSizeDips.H})
}
origin := f.align(fl.AlignRect, sizeDips, f.ascentDips, fl.H, fl.V)
for i, p := range offsets {
offsets[i] = p.Add(origin)
}
return offsets
}
示例5: DesiredSize
func (l *LinearLayout) DesiredSize(min, max math.Size) math.Size {
if l.sizeMode.Fill() {
return max
}
bounds := min.Rect()
children := l.outer.Children()
horizontal := l.direction.Orientation().Horizontal()
offset := math.Point{X: 0, Y: 0}
for _, c := range children {
cs := c.Control.DesiredSize(math.ZeroSize, max)
cm := c.Control.Margin()
cb := cs.Expand(cm).Rect().Offset(offset)
if horizontal {
offset.X += cb.W()
} else {
offset.Y += cb.H()
}
bounds = bounds.Union(cb)
}
return bounds.Size().Expand(l.outer.Padding()).Clamp(min, max)
}