Skip to content

Instantly share code, notes, and snippets.

@youpy
Forked from ucnv/rt.rb
Created May 24, 2010 19:40

Revisions

  1. youpy revised this gist May 25, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion banner.rb
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    http://github.com/youpy/pimento/blob/master/examples/banner.rb
    # http://github.com/youpy/pimento/blob/master/examples/banner.rb
  2. youpy revised this gist May 24, 2010. 1 changed file with 1 addition and 71 deletions.
    72 changes: 1 addition & 71 deletions banner.rb
    Original file line number Diff line number Diff line change
    @@ -1,71 +1 @@
    require 'ubygems'
    require 'pimento'

    str = ARGV.shift
    exit unless str =~ /^[\d\w ]+$/
    x = 50
    c = Pimento::Canvas.new 0,0,x+str.size*x*2,x*4
    d = [
    lambda {|i| c.line x+i*2*x,x,2*x+i*2*x,x },
    lambda {|i| c.line x+i*2*x,2*x,2*x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,3*x,2*x+i*2*x,3*x },
    lambda {|i| c.line x+i*2*x,x,x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,2*x,x+i*2*x,3*x },
    lambda {|i| c.line 2*x+i*2*x,x,2*x+i*2*x,2*x },
    lambda {|i| c.line 2*x+i*2*x,2*x,2*x+i*2*x,3*x },
    lambda {|i| c.line x+i*2*x,x,1.5*x+i*2*x,2*x },
    lambda {|i| c.line 1.5*x+i*2*x,2*x,2*x+i*2*x,x },
    lambda {|i| c.line x+i*2*x,3*x,1.5*x+i*2*x,2*x },
    lambda {|i| c.line 1.5*x+i*2*x,2*x,2*x+i*2*x,3*x },
    lambda {|i| c.line 1.5*x+i*2*x,2*x,2*x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,2*x,1.5*x+i*2*x,2*x },
    lambda {|i| c.line 1.5*x+i*2*x,x,1.5*x+i*2*x,2*x },
    lambda {|i| c.line 1.5*x+i*2*x,2*x,1.5*x+i*2*x,3*x },
    ]
    n = {
    ' ' => [],
    '0' => [0,2,3,4,5,6],
    '1' => [5,6],
    '2' => [0,1,2,5,4],
    '3' => [0,1,2,5,6],
    '4' => [1,3,5,6],
    '5' => [0,1,2,3,6],
    '6' => [0,1,2,3,4,6],
    '7' => [0,5,6],
    '8' => [0,1,2,3,4,5,6],
    '9' => [0,1,2,3,5,6],
    'A' => [0,1,3,4,5,6],
    'B' => [1,2,3,4,6],
    'C' => [0,2,3,4],
    'D' => [1,2,4,5,6],
    'E' => [0,1,2,3,4],
    'F' => [0,1,3,4],
    'G' => [0,2,3,4,6,11],
    'H' => [1,3,4,5,6],
    'I' => [13,14],
    'J' => [2,5,6],
    'K' => [3,4,8,10,12],
    'L' => [2,3,4],
    'M' => [0,3,4,5,6,13],
    'N' => [3,4,5,6,7,10],
    'O' => [0,2,3,4,5,6],
    'P' => [0,1,3,4,5],
    'Q' => [0,2,3,4,5,6,10],
    'R' => [0,1,3,4,5,10],
    'S' => [0,1,2,3,6],
    'T' => [0,13,14],
    'U' => [2,3,4,5,6],
    'V' => [3,4,8,9],
    'W' => [2,3,4,5,6,14],
    'X' => [7,8,9,10],
    'Y' => [1,2,3,5,6],
    'Z' => [0,2,8,9],
    }
    str.to_s.split(//).each_with_index do |ch, i|
    n[ch.upcase].reverse.each do |r|
    d[r].call i
    end
    end

    c.to_xml.save 'a.xib'
    #`open a.xib`
    http://github.com/youpy/pimento/blob/master/examples/banner.rb
  3. youpy revised this gist May 24, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions banner.rb
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@
    'J' => [2,5,6],
    'K' => [3,4,8,10,12],
    'L' => [2,3,4],
    'M' => [3,4,5,6,7,8],
    'M' => [0,3,4,5,6,13],
    'N' => [3,4,5,6,7,10],
    'O' => [0,2,3,4,5,6],
    'P' => [0,1,3,4,5],
    @@ -56,7 +56,7 @@
    'T' => [0,13,14],
    'U' => [2,3,4,5,6],
    'V' => [3,4,8,9],
    'W' => [3,4,5,6,9,10],
    'W' => [2,3,4,5,6,14],
    'X' => [7,8,9,10],
    'Y' => [1,2,3,5,6],
    'Z' => [0,2,8,9],
  4. youpy revised this gist May 24, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion banner.rb
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@
    'F' => [0,1,3,4],
    'G' => [0,2,3,4,6,11],
    'H' => [1,3,4,5,6],
    'I' => [5,6],
    'I' => [13,14],
    'J' => [2,5,6],
    'K' => [3,4,8,10,12],
    'L' => [2,3,4],
  5. youpy revised this gist May 24, 2010. 2 changed files with 71 additions and 37 deletions.
    71 changes: 71 additions & 0 deletions banner.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    require 'ubygems'
    require 'pimento'

    str = ARGV.shift
    exit unless str =~ /^[\d\w ]+$/
    x = 50
    c = Pimento::Canvas.new 0,0,x+str.size*x*2,x*4
    d = [
    lambda {|i| c.line x+i*2*x,x,2*x+i*2*x,x },
    lambda {|i| c.line x+i*2*x,2*x,2*x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,3*x,2*x+i*2*x,3*x },
    lambda {|i| c.line x+i*2*x,x,x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,2*x,x+i*2*x,3*x },
    lambda {|i| c.line 2*x+i*2*x,x,2*x+i*2*x,2*x },
    lambda {|i| c.line 2*x+i*2*x,2*x,2*x+i*2*x,3*x },
    lambda {|i| c.line x+i*2*x,x,1.5*x+i*2*x,2*x },
    lambda {|i| c.line 1.5*x+i*2*x,2*x,2*x+i*2*x,x },
    lambda {|i| c.line x+i*2*x,3*x,1.5*x+i*2*x,2*x },
    lambda {|i| c.line 1.5*x+i*2*x,2*x,2*x+i*2*x,3*x },
    lambda {|i| c.line 1.5*x+i*2*x,2*x,2*x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,2*x,1.5*x+i*2*x,2*x },
    lambda {|i| c.line 1.5*x+i*2*x,x,1.5*x+i*2*x,2*x },
    lambda {|i| c.line 1.5*x+i*2*x,2*x,1.5*x+i*2*x,3*x },
    ]
    n = {
    ' ' => [],
    '0' => [0,2,3,4,5,6],
    '1' => [5,6],
    '2' => [0,1,2,5,4],
    '3' => [0,1,2,5,6],
    '4' => [1,3,5,6],
    '5' => [0,1,2,3,6],
    '6' => [0,1,2,3,4,6],
    '7' => [0,5,6],
    '8' => [0,1,2,3,4,5,6],
    '9' => [0,1,2,3,5,6],
    'A' => [0,1,3,4,5,6],
    'B' => [1,2,3,4,6],
    'C' => [0,2,3,4],
    'D' => [1,2,4,5,6],
    'E' => [0,1,2,3,4],
    'F' => [0,1,3,4],
    'G' => [0,2,3,4,6,11],
    'H' => [1,3,4,5,6],
    'I' => [5,6],
    'J' => [2,5,6],
    'K' => [3,4,8,10,12],
    'L' => [2,3,4],
    'M' => [3,4,5,6,7,8],
    'N' => [3,4,5,6,7,10],
    'O' => [0,2,3,4,5,6],
    'P' => [0,1,3,4,5],
    'Q' => [0,2,3,4,5,6,10],
    'R' => [0,1,3,4,5,10],
    'S' => [0,1,2,3,6],
    'T' => [0,13,14],
    'U' => [2,3,4,5,6],
    'V' => [3,4,8,9],
    'W' => [3,4,5,6,9,10],
    'X' => [7,8,9,10],
    'Y' => [1,2,3,5,6],
    'Z' => [0,2,8,9],
    }
    str.to_s.split(//).each_with_index do |ch, i|
    n[ch.upcase].reverse.each do |r|
    d[r].call i
    end
    end

    c.to_xml.save 'a.xib'
    #`open a.xib`
    37 changes: 0 additions & 37 deletions rt.rb
    Original file line number Diff line number Diff line change
    @@ -1,37 +0,0 @@
    require 'ubygems'
    require 'pimento'

    id = ARGV.shift
    exit unless id =~ /^\d+$/
    x = 50
    c = Pimento::Canvas.new 0,0,x+id.size*x*2,x*4
    c.step = 12
    d = [
    lambda {|i| c.line x+i*2*x,x,2*x+i*2*x,x },
    lambda {|i| c.line x+i*2*x,2*x,2*x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,3*x,2*x+i*2*x,3*x },
    lambda {|i| c.line x+i*2*x,x,x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,2*x,x+i*2*x,3*x },
    lambda {|i| c.line 2*x+i*2*x,x,2*x+i*2*x,2*x },
    lambda {|i| c.line 2*x+i*2*x,2*x,2*x+i*2*x,3*x },
    ]
    n = {
    0 => [0,2,3,4,5,6],
    1 => [5,6],
    2 => [0,1,2,5,4],
    3 => [0,1,2,5,6],
    4 => [1,3,5,6],
    5 => [0,1,2,3,6],
    6 => [0,1,2,3,4,6],
    7 => [0,5,6],
    8 => [0,1,2,3,4,5,6],
    9 => [0,1,2,3,5,6]
    }
    id.each_char.with_index do |c, i|
    n[c.to_i].each do |r|
    d[r].call i
    end
    end

    c.to_xml.save 'a.xib'
    #`open a.xib`
  6. @ucnv ucnv revised this gist May 24, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rt.rb
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    exit unless id =~ /^\d+$/
    x = 50
    c = Pimento::Canvas.new 0,0,x+id.size*x*2,x*4
    c.step = 1
    c.step = 12
    d = [
    lambda {|i| c.line x+i*2*x,x,2*x+i*2*x,x },
    lambda {|i| c.line x+i*2*x,2*x,2*x+i*2*x,2*x },
  7. @ucnv ucnv created this gist May 24, 2010.
    37 changes: 37 additions & 0 deletions rt.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    require 'ubygems'
    require 'pimento'

    id = ARGV.shift
    exit unless id =~ /^\d+$/
    x = 50
    c = Pimento::Canvas.new 0,0,x+id.size*x*2,x*4
    c.step = 1
    d = [
    lambda {|i| c.line x+i*2*x,x,2*x+i*2*x,x },
    lambda {|i| c.line x+i*2*x,2*x,2*x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,3*x,2*x+i*2*x,3*x },
    lambda {|i| c.line x+i*2*x,x,x+i*2*x,2*x },
    lambda {|i| c.line x+i*2*x,2*x,x+i*2*x,3*x },
    lambda {|i| c.line 2*x+i*2*x,x,2*x+i*2*x,2*x },
    lambda {|i| c.line 2*x+i*2*x,2*x,2*x+i*2*x,3*x },
    ]
    n = {
    0 => [0,2,3,4,5,6],
    1 => [5,6],
    2 => [0,1,2,5,4],
    3 => [0,1,2,5,6],
    4 => [1,3,5,6],
    5 => [0,1,2,3,6],
    6 => [0,1,2,3,4,6],
    7 => [0,5,6],
    8 => [0,1,2,3,4,5,6],
    9 => [0,1,2,3,5,6]
    }
    id.each_char.with_index do |c, i|
    n[c.to_i].each do |r|
    d[r].call i
    end
    end

    c.to_xml.save 'a.xib'
    #`open a.xib`