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 // 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
} }

View File

@ -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 {