Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random pattern #32

Merged
merged 2 commits into from
Mar 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ You can then use this string to set the background:

![](http://jasonlong.github.io/geo_pattern/examples/triangles.png)

### triangles_rotated

![](http://jasonlong.github.io/geo_pattern/examples/triangles_rotated.png)

### squares

![](http://jasonlong.github.io/geo_pattern/examples/squares.png)
Expand Down
45 changes: 0 additions & 45 deletions lib/geo_pattern/pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class Pattern
tessellation
nested_squares
mosaic_squares
triangles_rotated
chevrons
].freeze

Expand Down Expand Up @@ -538,50 +537,6 @@ def geo_triangles
end
end

def geo_triangles_rotated
scale = hex_val(0, 1)
side_length = map(scale, 0, 15, 15, 80)
triangle_width = side_length/2 * Math.sqrt(3)
triangle = build_rotated_triangle_shape(side_length, triangle_width)

svg.set_width(triangle_width * 6)
svg.set_height(side_length * 3)

i = 0
for y in 0..5
for x in 0..5
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)

styles = {
"fill" => fill,
"fill-opacity" => opacity,
"stroke" => STROKE_COLOR,
"stroke-opacity" => STROKE_OPACITY
}

rotation = ""
if y % 2 == 0
rotation = x % 2 == 0 ? 180 : 0
else
rotation = x % 2 != 0 ? 180 : 0
end

svg.polyline(triangle, styles.merge({
"transform" => "translate(#{triangle_width*x}, #{y*side_length*0.5 - side_length/2}) rotate(#{rotation}, #{triangle_width/2}, #{side_length/2})"}))

# Add an extra one at top-right, for tiling.
if (y == 0)
svg.polyline(triangle, styles.merge({
"transform" => "translate(#{triangle_width*x}, #{6*side_length*0.5 - side_length/2}) rotate(#{rotation}, #{triangle_width/2}, #{side_length/2})"}))

end
i += 1
end
end
end

def geo_diamonds
diamond_width = map(hex_val(0, 1), 0, 15, 10, 50)
diamond_height = map(hex_val(1, 1), 0, 15, 10, 50)
Expand Down