fix pattern size regression

This commit is contained in:
Norwin Roosen 2020-12-29 21:09:00 +01:00
parent 1ca79d8e26
commit c3ee33f8ce
No known key found for this signature in database
GPG Key ID: 24BC059DE24C43A3
2 changed files with 3 additions and 4 deletions

View File

@ -11,7 +11,6 @@ import (
// Pattern provides infinite algorithmically generated Patterns and implements
// the image.Image interface.
type Pattern struct {
Size image.Point
}
// Image interface
@ -25,13 +24,13 @@ func (p *Pattern) ToFixedImage(bounds image.Rectangle) *image.NRGBA {
img := image.NewNRGBA(bounds)
// TODO: allow setting a mask?
// override size for pattern?
p.Size = bounds.Size() // override size for this Pattern
draw.Draw(img, bounds, p, image.Point{}, draw.Src)
return img
}
type StripePattern struct {
Pattern
Size int
Palette color.Palette
}
@ -41,7 +40,7 @@ func (c *StripePattern) At(x, y int) color.Color {
return color.Transparent
}
pxPerStripe := c.Size.Y / n
pxPerStripe := c.Size / n
if pxPerStripe <= 0 {
pxPerStripe = 1
}

View File

@ -158,7 +158,7 @@ func parseColorOrPalette(input string) image.Image {
}
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 {