Added a pseudorandom noise pattern
This commit is contained in:
parent
5edfbf8110
commit
c9c5f1d251
22
artist/noise.go
Normal file
22
artist/noise.go
Normal file
@ -0,0 +1,22 @@
|
||||
package artist
|
||||
|
||||
import "image/color"
|
||||
|
||||
// Noisy is a pattern that randomly interpolates between two patterns in a
|
||||
// deterministic fashion.
|
||||
type Noisy struct {
|
||||
Low Pattern
|
||||
High Pattern
|
||||
Seed uint32
|
||||
}
|
||||
|
||||
// AtWhen satisfies the pattern interface.
|
||||
func (pattern Noisy) AtWhen (x, y, width, height int) (c color.RGBA) {
|
||||
special := uint32(x + y * 348905)
|
||||
special += (pattern.Seed + 1) * 15485863
|
||||
random := (special * special * special % 2038074743)
|
||||
fac := float64(random) / 2038074743.0
|
||||
return LerpRGBA (
|
||||
pattern.Low.AtWhen(x, y, width, height),
|
||||
pattern.High.AtWhen(x, y, width, height), fac)
|
||||
}
|
@ -215,6 +215,17 @@ func (element *Artist) Resize (width, height int) {
|
||||
Stroke: artist.Stroke { Pattern: uhex(0x00FF00), Weight: 5 },
|
||||
},
|
||||
element.cellAt(0, 7))
|
||||
|
||||
// 1, 7
|
||||
artist.FillRectangle (
|
||||
element,
|
||||
artist.Noisy {
|
||||
Low: uhex(0x000000FF),
|
||||
High: uhex(0xFFFFFFFF),
|
||||
Seed: 0,
|
||||
},
|
||||
element.cellAt(1, 7),
|
||||
)
|
||||
}
|
||||
|
||||
func (element *Artist) lines (weight int, bounds image.Rectangle) {
|
||||
|
Reference in New Issue
Block a user