Skip to content

Commit

Permalink
cops: add Display.MergeRGBA
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorbin committed Dec 18, 2017
1 parent 6559a46 commit 684c6e6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/cops/display/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ func (d *Display) SetRGBA(x, y int, t string, f, b color.RGBA) {
}
}

// MergeRGBA sets the given string and colors if they are
// non-empty and not transparent respectively.
func (d *Display) MergeRGBA(x, y int, t string, f, b color.RGBA) {
if i := d.Text.StringsOffset(x, y); i >= 0 && i < len(d.Text.Strings) {
if t != "" {
d.Text.Strings[i] = t
}
if f.A > 0 {
// TODO blend < 0xff
d.Foreground.Pix[i] = f.R
d.Foreground.Pix[i+1] = f.G
d.Foreground.Pix[i+2] = f.B
d.Foreground.Pix[i+3] = f.A
}
if b.A > 0 {
// TODO blend < 0xff N.B also over Foreground
d.Background.Pix[i] = b.R
d.Background.Pix[i+1] = b.G
d.Background.Pix[i+2] = b.B
d.Background.Pix[i+3] = b.A
}
}
}

// TODO func (d *Display) Merge(x, y, t, f, b)

func (d *Display) setrgbai(i int, t string, f, b color.RGBA) {
d.Text.Strings[i] = t
j := i * 4
Expand Down

0 comments on commit 684c6e6

Please sign in to comment.