Sha256: 21e340253bf33d847eb306dde14d14ed02221da4cde29ece86e08aaac0d22c0f
Contents?: true
Size: 947 Bytes
Versions: 1
Compression:
Stored size: 947 Bytes
Contents
module Floorplanner class AreaBuilder < Geom::TriangleMesh attr_reader :ceiling_z def initialize(&block) super() @meshes = {} block.call(self) end def each(&block) @meshes.each_value{|a| block.call(a)} end def vertex(p) if existing = @vertices.index(p) @vertices[existing] else @vertices << p; p end end HEX_RE = "(?i:[a-f\\d])" def area(vertices,params=nil) a_id = vertices.hash.abs.to_s + "_" +params[:type] if params[:color] =~ /\A#((?:#{HEX_RE}{2,2}){3,4})\z/ params[:color] = [*$1.scan(/.{2,2}/).collect {|value| value.hex / 255.0}] else params[:color] = [1,1,1] end @meshes[a_id] = Geom::Polygon.new(vertices, nil, params.merge({:id => a_id})) end def update(ceiling_z) @ceiling_z = ceiling_z @meshes.each do |id,mesh| mesh.update end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
floorplanner-fml-0.2 | lib/floorplanner/area_builder.rb |