-
Notifications
You must be signed in to change notification settings - Fork 1
/
p4.rb
executable file
·51 lines (45 loc) · 3.02 KB
/
p4.rb
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env ruby
require 'nokogiri'
require 'pry'
html = Nokogiri::XML::Builder.new do
html do
head do
title "p4"
end
body do
svg do
defs do
g :id => "quarter" do
g do
path :d => "m 148.61869,148.90699 c -0.81971,-4.17225 -1.38896,-8.9842 -1.38896,-14.39467 0,-0.45504 1.08758,-1.56407 0.75762,-1.89403 -3.31143,-3.31143 -2.27284,-19.64631 -2.27284,-24.87501 0,-1.6064 3.20437,-5.50819 2.39911,-6.31345 -0.36277,-0.36278 -8.46103,-0.25254 -10.6066,-0.25254 -3.12218,0 6.05822,11.42869 2.14657,13.38452 -5.36977,2.68488 -4.1444,-6.56225 -7.95495,-7.19734 -2.036,-0.33933 -4.44629,-0.4285 -6.06092,0.37881 -0.3371,0.16855 -1.18298,5.13047 -0.63134,5.68211 3.9834,3.9834 9.71971,4.92148 11.49048,6.69226 1.06521,1.0652 1.18353,11.15878 2.65165,12.6269 1.53059,1.53059 8.84685,5.92664 5.93465,8.83884 -1.91902,1.91902 -12.91919,4.88475 -14.64721,3.15673 -2.02657,-2.02657 0.0697,-13.55434 -0.12627,-13.51079 -1.1248,0.24995 -7.4544,1.89856 -7.70241,2.14657 -2.7888,2.7888 3.12342,9.07149 -0.12627,11.23795 -1.10187,0.73457 -13.10591,2.55145 -12.50064,3.15672 3.08989,3.08989 33.65506,-2.18576 38.63833,1.13642 z", :fill => "rgb(233,206,135)"
end
g do
path :d => "m 103.03556,143.22489 c 3.33691,-0.28587 8.3497,0.86794 10.35406,-1.13642 2.8731,-2.8731 -9.36625,-9.71155 -3.28299,-12.75318 4.54069,-2.27035 0.14609,4.29315 3.28299,4.29315 2.42866,0 3.31287,-3.29296 5.55584,-4.04061 1.69469,-0.5649 8.67877,-0.34501 9.59645,-1.26269 0.18802,-0.18802 -0.12627,-1.3577 -0.12627,-1.6415 0,-0.33638 0.22106,-1.92552 0,-2.14658 -0.53503,-0.53503 -20.81875,-1.77819 -22.72843,-0.50507 -3.86554,2.57703 -0.5058,14.52599 -1.13642,18.94036", :fill => "rgb(205,147,56)"
end
g do
path :d => "m 125.51145,103.19759 c -2.63586,0.26491 -3.61981,0.29483 -4.54568,2.14658 -0.98461,1.96921 3.44247,15.27855 0.75761,15.27855 -3.50645,0 -14.90965,1.88414 -17.42513,-0.63134 -0.6848,-0.6848 0.12627,-1.25757 0.12627,-1.51523 0,-1.15574 -1.66507,-2.8924 -0.63135,-3.40927 2.88521,-1.4426 10.07312,2.17499 11.61676,0.63135 2.67544,-2.67544 -3.01297,-9.3614 0.63134,-13.00571 0.75805,-0.75805 6.83491,-2.07526 8.20749,-1.38896 1.08145,0.54072 1.51856,1.63817 1.89404,1.26269", :fill => "rgb(110,83,85)"
end
end
g :id => "tile" do
use :"xlink:href" => "#quarter"
use :"xlink:href" => "#quarter", :transform => "rotate(90,150,150)"
use :"xlink:href" => "#quarter", :transform => "rotate(180,150,150)"
use :"xlink:href" => "#quarter", :transform => "rotate(270,150,150)"
end
end
x1, y1 = 100,0
x2, y2 = 0,100
((-2)..15).each do |m|
((-2)..20).each do |n|
x_delta = m*x1 + n*x2
y_delta = m*y1 + n*y2
use :"xlink:href" => "#tile",:transform => "translate(#{x_delta},#{y_delta})"
end
end
end
end
end
end
out = File.new('output.html','w')
out.puts html.doc.to_html
out.close