ruby-processingでProcessing->Examples->Libraries->DXF Exportの写経

 写経してみた、けど動かなかったw;

ん〜、分らん...orz


load_library :dxf
import 'processing.dxf'
i
case :SimpleExport
when :SimpleExport
  def setup
    size 400,400,P3D
    no_stroke
    sphere_detail 12
    
    @recode = false
  end
  
  def draw
    beginRaw(DXF, "output.dxf") if @recode       #=> PGraphicsPDF requires an absolute path for the location of the output file. (NativeException)
    
    lights
    background 0
    
    translate width/3,height/3,-200
    rotate_z map(mouse_y, 0,height, 0,PI)
    rotate_y map(mouse_x, 0,width, 0, HALF_PI)
    -2.step(2-1){|y|
      -2.step(2-1){|x|
        -2.step(2-1){|z|
          push_matrix
          translate 120*x,120*y,-120*z
          sphere 30
          pop_matrix
        }
      }
    }
    
  end
  
  def key_pressed
    @recode = true if key == 'R' || key == 'r'
  end
  
end