-
Notifications
You must be signed in to change notification settings - Fork 0
/
ravello_round.rhtml
37 lines (29 loc) · 1011 Bytes
/
ravello_round.rhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<%
require './helpers.rb'
size = 500
thickness = 25
angle = -Math::PI*0.75
s1 = 50
s0 = s1 * Math.tan(Math::PI/8)
s2 = s1 + 2*s0
base_chain = [p(s0,s1), p(s2,s1), p(s2,-s1)]
base_commands = [' L ', " A #{s1} #{s1} 0 0 0 "]
chain = (0...8).map do |step|
base_chain.zip(base_commands).map { |(p, c)| p.rotate2d(step * angle).to2d_s + (c || "") }.join
end.join(' L ')
stroke_dashes = StrokeDash.new(-10,40,99,99,60.48)
page_intro("Ravello Round Knot")
%>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xml:lang="en" viewBox="<%= -size/2 %> <%= -size/2 %> <%= size %> <%= size %>" id="knot">
<defs>
<style>
.top, .bottom { stroke-width: <%= thickness %>px; fill: none; }
.top { stroke: #E09989; }
.bottom { stroke: #E8E1D3; }
.top { <%= stroke_dashes.css %> }
</style>
<path id="path-a" d="M <%= chain %> Z" />
</defs>
<use xlink:href="#path-a" class="bottom" />
<use xlink:href="#path-a" class="top" />
</svg>