Created a Tiled pattern
This commit is contained in:
parent
269c70ebb1
commit
3949f2af9e
@ -26,8 +26,26 @@ func (pattern Checkered) AtWhen (x, y, width, height int) (c color.RGBA) {
|
|||||||
y %= pattern.CellHeight
|
y %= pattern.CellHeight
|
||||||
|
|
||||||
if n % 2 == 0 {
|
if n % 2 == 0 {
|
||||||
return pattern.First.AtWhen(x, y, pattern.CellWidth, pattern.CellHeight)
|
return pattern.First.AtWhen (
|
||||||
|
x, y, pattern.CellWidth, pattern.CellHeight)
|
||||||
} else {
|
} else {
|
||||||
return pattern.Second.AtWhen(x, y, pattern.CellWidth, pattern.CellHeight)
|
return pattern.Second.AtWhen (
|
||||||
|
x, y, pattern.CellWidth, pattern.CellHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tiled is a pattern that tiles another pattern accross a grid.
|
||||||
|
type Tiled struct {
|
||||||
|
Pattern
|
||||||
|
CellWidth, CellHeight int
|
||||||
|
}
|
||||||
|
|
||||||
|
// AtWhen satisfies the Pattern interface.
|
||||||
|
func (pattern Tiled) AtWhen (x, y, width, height int) (c color.RGBA) {
|
||||||
|
x %= pattern.CellWidth
|
||||||
|
y %= pattern.CellHeight
|
||||||
|
if x < 0 { x += pattern.CellWidth }
|
||||||
|
if y < 0 { y += pattern.CellHeight }
|
||||||
|
return pattern.Pattern.AtWhen (
|
||||||
|
x, y, pattern.CellWidth, pattern.CellHeight)
|
||||||
|
}
|
||||||
|
@ -175,6 +175,21 @@ func (element *Artist) Resize (width, height int) {
|
|||||||
Spacing: 16,
|
Spacing: 16,
|
||||||
},
|
},
|
||||||
element.cellAt(2, 5))
|
element.cellAt(2, 5))
|
||||||
|
|
||||||
|
// 3, 5
|
||||||
|
artist.FillRectangle (
|
||||||
|
element,
|
||||||
|
artist.Tiled {
|
||||||
|
Pattern: artist.QuadBeveled {
|
||||||
|
artist.NewUniform(hex(0x880000FF)),
|
||||||
|
artist.NewUniform(hex(0x00FF00FF)),
|
||||||
|
artist.NewUniform(hex(0x0000FFFF)),
|
||||||
|
artist.NewUniform(hex(0xFF00FFFF)),
|
||||||
|
},
|
||||||
|
CellWidth: 17,
|
||||||
|
CellHeight: 23,
|
||||||
|
},
|
||||||
|
element.cellAt(3, 5))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Artist) lines (weight int, bounds image.Rectangle) {
|
func (element *Artist) lines (weight int, bounds image.Rectangle) {
|
||||||
|
Reference in New Issue
Block a user