f32: [API] unexport Rectangle

There are no public API that uses f32.Rectangle anymore. Move Rectangle
to an internal package for internal use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-04-26 10:56:13 +02:00
parent fc79ec5c94
commit b5f12c5f26
15 changed files with 54 additions and 258 deletions
+4 -17
View File
@@ -9,6 +9,7 @@ import (
"math"
"gioui.org/f32"
f32internal "gioui.org/internal/f32"
"gioui.org/internal/ops"
"gioui.org/internal/scene"
"gioui.org/internal/stroke"
@@ -51,7 +52,7 @@ func (p Op) add(o *op.Ops) {
if !path.hasSegments && p.width > 0 {
switch p.path.shape {
case ops.Rect:
b := frect(path.bounds)
b := f32internal.FRect(path.bounds)
var rect Path
rect.Begin(o)
rect.MoveTo(b.Min)
@@ -129,7 +130,7 @@ type Path struct {
macro op.MacroOp
start f32.Point
hasSegments bool
bounds f32.Rectangle
bounds f32internal.Rectangle
hash maphash.Hash
}
@@ -219,7 +220,7 @@ func (p *Path) cmd(data []byte, c scene.Command) {
func (p *Path) expand(pt f32.Point) {
if !p.hasSegments {
p.hasSegments = true
p.bounds = f32.Rectangle{Min: pt, Max: pt}
p.bounds = f32internal.Rectangle{Min: pt, Max: pt}
} else {
b := p.bounds
if pt.X < b.Min.X {
@@ -339,17 +340,3 @@ func (o Outline) Op() Op {
outline: true,
}
}
// frect converts a rectangle to a f32.Rectangle.
func frect(r image.Rectangle) f32.Rectangle {
return f32.Rectangle{
Min: fpt(r.Min), Max: fpt(r.Max),
}
}
// fpt converts an point to a f32.Point.
func fpt(p image.Point) f32.Point {
return f32.Point{
X: float32(p.X), Y: float32(p.Y),
}
}
+3 -2
View File
@@ -7,6 +7,7 @@ import (
"math"
"gioui.org/f32"
f32internal "gioui.org/internal/f32"
"gioui.org/internal/ops"
"gioui.org/op"
)
@@ -81,7 +82,7 @@ func (rr RRect) Path(ops *op.Ops) PathSpec {
const iq = 1 - q
se, sw, nw, ne := float32(rr.SE), float32(rr.SW), float32(rr.NW), float32(rr.NE)
rrf := frect(rr.Rect)
rrf := f32internal.FRect(rr.Rect)
w, n, e, s := rrf.Min.X, rrf.Min.Y, rrf.Max.X, rrf.Max.Y
p.MoveTo(f32.Point{X: w + nw, Y: n})
@@ -133,7 +134,7 @@ func (e Ellipse) Path(o *op.Ops) PathSpec {
var p Path
p.Begin(o)
bf := frect(bounds)
bf := f32internal.FRect(bounds)
center := bf.Max.Add(bf.Min).Mul(.5)
diam := bf.Dx()
r := diam * .5