This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/artist/chisel.go

34 lines
733 B
Go
Raw Normal View History

2023-01-08 23:03:19 -07:00
package artist
import "image/color"
// Chiseled is a pattern that has a highlight section and a shadow section.
type Chiseled struct {
Highlight Pattern
Shadow Pattern
2023-01-08 23:03:19 -07:00
}
// AtWhen satisfies the Pattern interface.
func (chiseled Chiseled) AtWhen (x, y, width, height int) (c color.RGBA) {
2023-01-20 16:39:08 -07:00
var highlighted bool
var bottomCorner bool
2023-01-20 16:08:20 -07:00
if width > height {
bottomCorner = y > height / 2
} else {
bottomCorner = x < width / 2
}
if bottomCorner {
highlighted = float64(x) < float64(height) - float64(y)
} else {
highlighted = float64(width) - float64(x) > float64(y)
}
if highlighted {
return chiseled.Highlight.AtWhen(x, y, width, height)
} else {
return chiseled.Shadow.AtWhen(x, y, width, height)
2023-01-08 23:03:19 -07:00
}
}