Skip to content

Commit

Permalink
more models
Browse files Browse the repository at this point in the history
  • Loading branch information
kpym committed Apr 20, 2021
1 parent 1107183 commit 088bb95
Show file tree
Hide file tree
Showing 16 changed files with 242 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand Down
10 changes: 8 additions & 2 deletions pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func (g *generator) Generate() (svg []byte, ok bool) {
g.scale,
}

if !g.templateOk {
g.addError("Can't generate the pattern: no svg model selected.")
return nil, false
}
err := g.code.Execute(&result, data)
if err != nil {
g.addError("Error executing the template " + g.name)
Expand Down Expand Up @@ -184,7 +188,9 @@ func (g *generator) setModel(index int) {
code, err := template.New(g.name).Funcs(rf).Funcs(uf).Parse(m.Code)
if err != nil {
g.addError("Error parsing template " + g.name + ": " + err.Error())
return
}

g.code = code
g.templateOk = true
}
Expand All @@ -196,7 +202,7 @@ func (g *generator) randomModel() {

// WithModel is a Generator option that select the model
// from the list of 'valid' models.
// If only one valid model name is provided it is used.
// If only one valid model name is provided, it is used.
// If no such model is provided, then a random one is
// chosen among all models.
func WithModel(models ...string) Option {
Expand Down Expand Up @@ -249,7 +255,7 @@ func (g *generator) setOpacity(opacity float64) {

// randomColor generate a random background color.
func (g *generator) randomColor() {
randCol := colorful.Hsl(360*g.rand.Float64(), 0.4+0.3*g.rand.Float64(), 0.3+0.4*g.rand.Float64())
randCol := colorful.Hsl(360*g.rand.Float64(), 0.4+0.3*g.rand.Float64(), 0.4+0.1*g.rand.Float64())
g.setColor(randCol)
}

Expand Down
6 changes: 3 additions & 3 deletions template/model/svgmodels/chevrons.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions template/model/svgmodels/diamonds.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions template/model/svgmodels/mosaic-squares.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions template/model/svgmodels/nested-squares.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions template/model/svgmodels/octagons.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions template/model/svgmodels/overlapping-circles.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions template/model/svgmodels/overlapping-rings.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions template/model/svgmodels/plaid.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions template/model/svgmodels/plus-signs.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions template/model/svgmodels/rectangles.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions template/model/svgmodels/sin-waves.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions template/model/svgmodels/squares.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 088bb95

Please sign in to comment.