mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
op/paint: add opacity operation
The new paint.PushOpacity allows for adjusting the opacity of a group of drawing operations. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -413,6 +413,22 @@ func TestGapsInPath(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestOpacity(t *testing.T) {
|
||||
run(t, func(ops *op.Ops) {
|
||||
opc1 := paint.PushOpacity(ops, .3)
|
||||
// Fill screen to exercize the glClear optimization.
|
||||
paint.FillShape(ops, color.NRGBA{R: 255, A: 255}, clip.Rect{Max: image.Pt(1024, 1024)}.Op())
|
||||
opc2 := paint.PushOpacity(ops, .6)
|
||||
paint.FillShape(ops, color.NRGBA{G: 255, A: 255}, clip.Rect{Min: image.Pt(20, 10), Max: image.Pt(64, 128)}.Op())
|
||||
opc2.Pop()
|
||||
opc1.Pop()
|
||||
opc3 := paint.PushOpacity(ops, .6)
|
||||
paint.FillShape(ops, color.NRGBA{G: 255, A: 255}, clip.Rect{Min: image.Pt(50+20, 10), Max: image.Pt(50+64, 128)}.Op())
|
||||
opc3.Pop()
|
||||
}, func(r result) {
|
||||
})
|
||||
}
|
||||
|
||||
// lerp calculates linear interpolation with color b and p.
|
||||
func lerp(a, b f32color.RGBA, p float32) f32color.RGBA {
|
||||
return f32color.RGBA{
|
||||
|
||||
Reference in New Issue
Block a user