Sha256: 6bba29cce31358223b6c59e31d0dade699717ba22d70aa287552e262aab29116
Contents?: true
Size: 804 Bytes
Versions: 1
Compression:
Stored size: 804 Bytes
Contents
#!/usr/bin/env ruby require "ulaminate" require "optparse" require "chunky_png" Options = Struct.new(:size) options = Options.new(7) OptionParser.new do |parser| parser.banner = "Usage: ulaminate [options]" parser.on("-h", "--help", "Prints this help") do puts parser exit end parser.on("--size SIZE", Integer, "The size of the side of the spiral") do |size| options.size = size end end.parse! png = ChunkyPNG::Image.new(options.size, options.size, ChunkyPNG::Color::WHITE) begin sequence = Ulaminate.ulam_sequence(options.size) loop do x, y, _, is_prime = sequence.next next unless is_prime png[x, y] = ChunkyPNG::Color::BLACK end rescue StopIteration # swallow sequence end end puts png.save("ulam_spiral_#{options.size}.png", :best_compression).path
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ulaminate-0.1.0 | exe/ulaminate |