3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/floorplanner/svg_export.rb', line 3
def to_svg
bbox = @walls.bounding_box
dx = bbox[:min].distance_x(bbox[:max])
dy = bbox[:min].distance_y(bbox[:max])
min_x = -bbox[:min].x
min_y = -bbox[:min].y
width , height , padding = Floorplanner.config['svg']['width'],
Floorplanner.config['svg']['height'],
Floorplanner.config['svg']['padding']
ratio = ( width < height ? width : height ) * padding / ( dx > dy ? dx : dy )
mod_x = min_x + (width /ratio)/2 - dx/2
mod_y = min_y + (height/ratio)/2 - dy/2
template = ERB.new(
File.read(
File.join(Floorplanner.config['views_path'],'design.svg.erb')))
template.result(binding)
end
|