fix pattern size regression
This commit is contained in:
parent
1ca79d8e26
commit
c3ee33f8ce
|
@ -11,7 +11,6 @@ import (
|
||||||
// Pattern provides infinite algorithmically generated Patterns and implements
|
// Pattern provides infinite algorithmically generated Patterns and implements
|
||||||
// the image.Image interface.
|
// the image.Image interface.
|
||||||
type Pattern struct {
|
type Pattern struct {
|
||||||
Size image.Point
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Image interface
|
// Image interface
|
||||||
|
@ -25,13 +24,13 @@ func (p *Pattern) ToFixedImage(bounds image.Rectangle) *image.NRGBA {
|
||||||
img := image.NewNRGBA(bounds)
|
img := image.NewNRGBA(bounds)
|
||||||
// TODO: allow setting a mask?
|
// TODO: allow setting a mask?
|
||||||
// override size for pattern?
|
// override size for pattern?
|
||||||
p.Size = bounds.Size() // override size for this Pattern
|
|
||||||
draw.Draw(img, bounds, p, image.Point{}, draw.Src)
|
draw.Draw(img, bounds, p, image.Point{}, draw.Src)
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
|
||||||
type StripePattern struct {
|
type StripePattern struct {
|
||||||
Pattern
|
Pattern
|
||||||
|
Size int
|
||||||
Palette color.Palette
|
Palette color.Palette
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ func (c *StripePattern) At(x, y int) color.Color {
|
||||||
return color.Transparent
|
return color.Transparent
|
||||||
}
|
}
|
||||||
|
|
||||||
pxPerStripe := c.Size.Y / n
|
pxPerStripe := c.Size / n
|
||||||
if pxPerStripe <= 0 {
|
if pxPerStripe <= 0 {
|
||||||
pxPerStripe = 1
|
pxPerStripe = 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ func parseColorOrPalette(input string) image.Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
if pal := render.PrideFlags[input]; len(pal) != 0 {
|
if pal := render.PrideFlags[input]; len(pal) != 0 {
|
||||||
return &render.StripePattern{Palette: pal}
|
return &render.StripePattern{Palette: pal, Size: 13}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p, ok := render.DynPatterns[input]; ok {
|
if p, ok := render.DynPatterns[input]; ok {
|
||||||
|
|
Loading…
Reference in New Issue