Skip to content

Commit

Permalink
add diamond pattern and format geo_diamonds method
Browse files Browse the repository at this point in the history
  • Loading branch information
pravj committed Oct 28, 2014
1 parent d8f3bcf commit f46acc7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Uri_image(args)
###### concentric_circles
![Concentric_Circles](https://raw.githubusercontent.com/pravj/geo_pattern/master/examples/patterns/concentric_circles.png)

###### diamonds
![Diamonds](https://raw.githubusercontent.com/pravj/geo_pattern/master/examples/patterns/diamonds.png)

###### hexagons
![Hexagons](https://raw.githubusercontent.com/pravj/geo_pattern/master/examples/patterns/hexagons.png)

Expand Down
Binary file modified examples/patterns/diamonds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/patterns/hexagons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions pattern/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,21 @@ func (p *Pattern) geo_diamonds() {

style := make(map[string]interface{})

style["transform"] = fmt.Sprintf("translate(%v, %v)", float64(x)*diamond_width-diamond_width/2+dx, diamond_height/2*float64(y)-diamond_height/2)
style["transform"] = fmt.Sprintf("translate(%v, %v)", dx + float64(x)*diamond_width - diamond_width/2, diamond_height/2*float64(y) - diamond_height/2)
p.Svg.Polyline(diamond, utils.Merge(styles, style))

if x == 0 {
style["transform"] = fmt.Sprintf("translate(%v, %v)", 6*diamond_width-diamond_width/2+dx, diamond_height/2*float64(y)-diamond_height/2)
style["transform"] = fmt.Sprintf("translate(%v, %v)", dx + 6*diamond_width - diamond_width/2, diamond_height/2*float64(y) - diamond_height/2)
p.Svg.Polyline(diamond, utils.Merge(styles, style))
}

if y == 0 {
style["transform"] = fmt.Sprintf("translate(%v, %v)", float64(x)*diamond_width-diamond_width/2+dx, diamond_height/2*6-diamond_height/2)
style["transform"] = fmt.Sprintf("translate(%v, %v)", dx + float64(x)*diamond_width - diamond_width/2, diamond_height/2*6 - diamond_height/2)
p.Svg.Polyline(diamond, utils.Merge(styles, style))
}

if x == 0 && y == 0 {
style["transform"] = fmt.Sprintf("translate(%v, %v)", 6*diamond_width-diamond_width/2+dx, diamond_height/2*6-diamond_height/2)
style["transform"] = fmt.Sprintf("translate(%v, %v)", dx + 6*diamond_width - diamond_width/2, diamond_height/2*6 - diamond_height/2)
p.Svg.Polyline(diamond, utils.Merge(styles, style))
}

Expand Down

0 comments on commit f46acc7

Please sign in to comment.