forked from joejulian/gio
op/clip: remove Border
Border can be expressed in-terms of clip.Stroke:
clip.Stroke{
Path: clip.UniformRRect(r, rr).Ops(ops),
Style: clip.StrokeStyle{Width: width},
}.Add(ops)
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
@@ -37,29 +37,6 @@ func TestPaintClippedRect(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestPaintClippedBorder(t *testing.T) {
|
||||
t.Skipf("doesn't render round-capped, round-joined dashes correctly")
|
||||
run(t, func(o *op.Ops) {
|
||||
var dashes clip.Dash
|
||||
dashes.Begin(o)
|
||||
dashes.Phase(1)
|
||||
dashes.Dash(2)
|
||||
dashes.Dash(1)
|
||||
|
||||
clip.Border{
|
||||
Rect: f32.Rect(25, 25, 60, 60),
|
||||
Width: 4,
|
||||
Dashes: dashes.End(),
|
||||
}.Add(o)
|
||||
paint.FillShape(o, red, clip.Rect(image.Rect(0, 0, 50, 50)).Op())
|
||||
}, func(r result) {
|
||||
r.expect(0, 0, colornames.White)
|
||||
r.expect(25, 25, colornames.Red)
|
||||
r.expect(50, 0, colornames.White)
|
||||
r.expect(10, 50, colornames.White)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPaintClippedCircle(t *testing.T) {
|
||||
run(t, func(o *op.Ops) {
|
||||
r := float32(10)
|
||||
|
||||
@@ -96,38 +96,6 @@ func (rr RRect) Path(ops *op.Ops) PathSpec {
|
||||
return p.End()
|
||||
}
|
||||
|
||||
// Border represents a rectangular border.
|
||||
type Border struct {
|
||||
// Rect is the bounds of the border.
|
||||
Rect f32.Rectangle
|
||||
// Width of the line tracing Rect.
|
||||
Width float32
|
||||
Dashes DashSpec
|
||||
// The corner radii.
|
||||
SE, SW, NW, NE float32
|
||||
}
|
||||
|
||||
// Op returns the clip operation for the border. Its area corresponds to a
|
||||
// stroked line that traces the border rectangle, optionally with rounded
|
||||
// corners and dashes.
|
||||
func (b Border) Op(ops *op.Ops) Op {
|
||||
return Stroke{
|
||||
Path: RRect{
|
||||
Rect: b.Rect,
|
||||
SE: b.SE, SW: b.SW, NW: b.NW, NE: b.NE,
|
||||
}.Path(ops),
|
||||
Style: StrokeStyle{
|
||||
Width: b.Width,
|
||||
},
|
||||
Dashes: b.Dashes,
|
||||
}.Op()
|
||||
}
|
||||
|
||||
// Add the border clip.
|
||||
func (rr Border) Add(ops *op.Ops) {
|
||||
rr.Op(ops).Add(ops)
|
||||
}
|
||||
|
||||
// Circle represents the clip area of a circle.
|
||||
type Circle struct {
|
||||
Center f32.Point
|
||||
|
||||
Reference in New Issue
Block a user