aboutsummaryrefslogtreecommitdiff
path: root/externals/gridflow/bin/hpgl_move
blob: f4bf0534a75d0ad11122512a665e5a0d3d89119c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env ruby
# Copyright (c) 2009 by Mathieu Bouchard

x = Float ARGV[0]
y = Float ARGV[1]

puts STDIN.read.split(/\s*;\s*/).map {|m|
  h = m.slice!(0,2)
  d = m.split(",")
  case h
  when "PA","PD","PU"
    (0...d.length).each {|i|
      off = if i%2==0 then x else y end
      v = Float(d[i])+off
      d[i] = if v==v.to_i then v.to_i else v.to_f end
    }
  end
  h+d.join(",")
}.join(";")