mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
cmd,example: fix uses of color.NRGBA
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ module gioui.org/cmd
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
gioui.org v0.0.0-20201105153338-edaa112c40df
|
||||
gioui.org v0.0.0-20201119103011-21ef492cc9df
|
||||
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4
|
||||
github.com/chromedp/chromedp v0.5.2
|
||||
golang.org/x/image v0.0.0-20200618115811-c13761719519
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
gioui.org v0.0.0-20201105153338-edaa112c40df h1:GfuHya3d2IqsgScxQ5RHaz2n4y3KnGPv+ogcs1l7ZCY=
|
||||
gioui.org v0.0.0-20201105153338-edaa112c40df/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
|
||||
gioui.org v0.0.0-20201119103011-21ef492cc9df h1:rbPrGAuu3VRB5ip6X8v1NN+P79oWEBGWYEI+Qreqvpg=
|
||||
gioui.org v0.0.0-20201119103011-21ef492cc9df/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4 h1:QD3KxSJ59L2lxG6MXBjNHxiQO2RmxTQ3XcK+wO44WOg=
|
||||
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4/go.mod h1:PfAWWKJqjlGFYJEidUM6aVIWPr0EpobeyVWEEmplX7g=
|
||||
|
||||
@@ -96,11 +96,11 @@ func runEndToEndTest(t *testing.T, driver TestDriver) {
|
||||
t.Log("starting driver and gio app")
|
||||
driver.Start("testdata/red.go")
|
||||
|
||||
beef := color.RGBA{R: 0xde, G: 0xad, B: 0xbe}
|
||||
white := color.RGBA{R: 0xff, G: 0xff, B: 0xff}
|
||||
black := color.RGBA{R: 0x00, G: 0x00, B: 0x00}
|
||||
gray := color.RGBA{R: 0xbb, G: 0xbb, B: 0xbb}
|
||||
red := color.RGBA{R: 0xff, G: 0x00, B: 0x00}
|
||||
beef := color.NRGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff}
|
||||
white := color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||
black := color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff}
|
||||
gray := color.NRGBA{R: 0xbb, G: 0xbb, B: 0xbb, A: 0xff}
|
||||
red := color.NRGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff}
|
||||
|
||||
// These are the four colors at the beginning.
|
||||
t.Log("taking initial screenshot")
|
||||
@@ -181,7 +181,7 @@ func (m colorMismatch) String() string {
|
||||
)
|
||||
}
|
||||
|
||||
func checkImageCorners(img image.Image, topLeft, topRight, botLeft, botRight color.RGBA) error {
|
||||
func checkImageCorners(img image.Image, topLeft, topRight, botLeft, botRight color.Color) error {
|
||||
// The colors are split in four rectangular sections. Check the corners
|
||||
// of each of the sections. We check the corners left to right, top to
|
||||
// bottom, like when reading left-to-right text.
|
||||
|
||||
Vendored
+7
-7
@@ -47,16 +47,16 @@ type (
|
||||
|
||||
func loop(w *app.Window) error {
|
||||
topLeft := quarterWidget{
|
||||
color: color.RGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff},
|
||||
color: color.NRGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff},
|
||||
}
|
||||
topRight := quarterWidget{
|
||||
color: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||
color: color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||
}
|
||||
botLeft := quarterWidget{
|
||||
color: color.RGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff},
|
||||
color: color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff},
|
||||
}
|
||||
botRight := quarterWidget{
|
||||
color: color.RGBA{R: 0x00, G: 0x00, B: 0x00, A: 0x80},
|
||||
color: color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0x80},
|
||||
}
|
||||
|
||||
var ops op.Ops
|
||||
@@ -103,15 +103,15 @@ func loop(w *app.Window) error {
|
||||
// quarterWidget paints a quarter of the screen with one color. When clicked, it
|
||||
// turns red, going back to its normal color when clicked again.
|
||||
type quarterWidget struct {
|
||||
color color.RGBA
|
||||
color color.NRGBA
|
||||
|
||||
clicked bool
|
||||
}
|
||||
|
||||
var red = color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff}
|
||||
var red = color.NRGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff}
|
||||
|
||||
func (w *quarterWidget) Layout(gtx layout.Context) layout.Dimensions {
|
||||
var color color.RGBA
|
||||
var color color.NRGBA
|
||||
if w.clicked {
|
||||
color = red
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ module gioui.org/example
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
gioui.org v0.0.0-20201110142722-9843176adbff
|
||||
gioui.org v0.0.0-20201119103011-21ef492cc9df
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72
|
||||
github.com/google/go-github/v24 v24.0.1
|
||||
|
||||
+2
-4
@@ -1,7 +1,7 @@
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
gioui.org v0.0.0-20201110142722-9843176adbff h1:HhXpR5RaVpz3/NFNHK0GAb8tGaR95GOW/oUrSPdm5gQ=
|
||||
gioui.org v0.0.0-20201110142722-9843176adbff/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
|
||||
gioui.org v0.0.0-20201119103011-21ef492cc9df h1:rbPrGAuu3VRB5ip6X8v1NN+P79oWEBGWYEI+Qreqvpg=
|
||||
gioui.org v0.0.0-20201119103011-21ef492cc9df/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
|
||||
@@ -24,7 +24,6 @@ golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL
|
||||
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 h1:n9HxLrNxWWtEb1cA950nuEEj3QnKbtsCJ6KjcgisNUs=
|
||||
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200618115811-c13761719519 h1:1e2ufUJNM3lCHEY5jIgac/7UTjd6cgJNdatjPdFWf34=
|
||||
golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
@@ -39,7 +38,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
||||
@@ -102,12 +102,12 @@ func newUI(fetchCommits func(string)) *UI {
|
||||
return u
|
||||
}
|
||||
|
||||
func rgb(c uint32) color.RGBA {
|
||||
func rgb(c uint32) color.NRGBA {
|
||||
return argb((0xff << 24) | c)
|
||||
}
|
||||
|
||||
func argb(c uint32) color.RGBA {
|
||||
return color.RGBA{A: uint8(c >> 24), R: uint8(c >> 16), G: uint8(c >> 8), B: uint8(c)}
|
||||
func argb(c uint32) color.NRGBA {
|
||||
return color.NRGBA{A: uint8(c >> 24), R: uint8(c >> 16), G: uint8(c >> 8), B: uint8(c)}
|
||||
}
|
||||
|
||||
func (u *UI) layoutTimings(gtx layout.Context) {
|
||||
@@ -321,7 +321,7 @@ func (u *user) layoutAvatar(gtx layout.Context) layout.Dimensions {
|
||||
}
|
||||
|
||||
type fill struct {
|
||||
col color.RGBA
|
||||
col color.NRGBA
|
||||
}
|
||||
|
||||
func (f fill) Layout(gtx layout.Context) layout.Dimensions {
|
||||
|
||||
@@ -41,7 +41,7 @@ func loop(w *app.Window) error {
|
||||
case system.FrameEvent:
|
||||
gtx := layout.NewContext(&ops, e)
|
||||
l := material.H1(th, "Hello, Gio")
|
||||
maroon := color.RGBA{127, 0, 0, 255}
|
||||
maroon := color.NRGBA{R: 127, G: 0, B: 0, A: 255}
|
||||
l.Color = maroon
|
||||
l.Alignment = text.Middle
|
||||
l.Layout(gtx)
|
||||
|
||||
@@ -258,7 +258,7 @@ func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
|
||||
func(gtx C) D {
|
||||
e := material.Editor(th, lineEditor, "Hint")
|
||||
e.Font.Style = text.Italic
|
||||
border := widget.Border{Color: color.RGBA{A: 0xff}, CornerRadius: unit.Dp(8), Width: unit.Px(2)}
|
||||
border := widget.Border{Color: color.NRGBA{A: 0xff}, CornerRadius: unit.Dp(8), Width: unit.Px(2)}
|
||||
return border.Layout(gtx, func(gtx C) D {
|
||||
return layout.UniformInset(unit.Dp(8)).Layout(gtx, e.Layout)
|
||||
})
|
||||
@@ -272,8 +272,8 @@ func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
|
||||
paint.LinearGradientOp{
|
||||
Stop1: layout.FPt(dr.Min),
|
||||
Stop2: layout.FPt(dr.Max),
|
||||
Color1: color.RGBA{0x10, 0xff, 0x10, 0xFF},
|
||||
Color2: color.RGBA{0x10, 0x10, 0xff, 0xFF},
|
||||
Color1: color.NRGBA{R: 0x10, G: 0xff, B: 0x10, A: 0xFF},
|
||||
Color2: color.NRGBA{R: 0x10, G: 0x10, B: 0xff, A: 0xFF},
|
||||
}.Add(gtx.Ops)
|
||||
clip.Rect(dr).Add(gtx.Ops)
|
||||
paint.PaintOp{}.Add(gtx.Ops)
|
||||
@@ -306,7 +306,7 @@ func kitchen(gtx layout.Context, th *material.Theme) layout.Dimensions {
|
||||
}
|
||||
btn := material.Button(th, greenButton, l)
|
||||
if green {
|
||||
btn.Background = color.RGBA{A: 0xff, R: 0x9e, G: 0x9d, B: 0x24}
|
||||
btn.Background = color.NRGBA{A: 0xff, R: 0x9e, G: 0x9d, B: 0x24}
|
||||
}
|
||||
return btn.Layout(gtx)
|
||||
})
|
||||
|
||||
@@ -127,17 +127,16 @@ func drawTabs(gtx layout.Context, th *material.Theme) layout.Dimensions {
|
||||
)
|
||||
}
|
||||
|
||||
func fill(gtx layout.Context, col1, col2 color.RGBA) {
|
||||
func fill(gtx layout.Context, col1, col2 color.NRGBA) {
|
||||
dr := image.Rectangle{Max: gtx.Constraints.Min}
|
||||
paint.FillShape(gtx.Ops,
|
||||
color.RGBA{R: 0, G: 0, B: 0, A: 0xFF},
|
||||
color.NRGBA{R: 0, G: 0, B: 0, A: 0xFF},
|
||||
clip.Rect(dr).Op(),
|
||||
)
|
||||
|
||||
col2.R = byte(float32(col2.R))
|
||||
col2.G = byte(float32(col2.G))
|
||||
col2.B = byte(float32(col2.B))
|
||||
col2.A = byte(float32(col2.A) * 0.2)
|
||||
paint.LinearGradientOp{
|
||||
Stop1: f32.Pt(float32(dr.Min.X), 0),
|
||||
Stop2: f32.Pt(float32(dr.Max.X), 0),
|
||||
@@ -149,9 +148,9 @@ func fill(gtx layout.Context, col1, col2 color.RGBA) {
|
||||
paint.PaintOp{}.Add(gtx.Ops)
|
||||
}
|
||||
|
||||
func dynamicColor(i int) color.RGBA {
|
||||
func dynamicColor(i int) color.NRGBA {
|
||||
sn, cs := math.Sincos(float64(i) * math.Phi)
|
||||
return color.RGBA{
|
||||
return color.NRGBA{
|
||||
R: 0xA0 + byte(0x30*sn),
|
||||
G: 0xA0 + byte(0x30*cs),
|
||||
B: 0xD0,
|
||||
|
||||
Reference in New Issue
Block a user