require 'rubygems' require 'png' def f(x, y) ( (x ^ y) & ((y - 350) >> 3) ) ** 2 end canvas = PNG::Canvas.new(500, 500) 0.upto(499) do |y| 0.upto(499) do |x| canvas[x, 499 - y] = ((f(x, y) >> 12) & 1) == 1 ? PNG::Color::Black : PNG::Color::White end end png = PNG.new(canvas) png.save 'pattern.png'
You need to create an account or log in to post comments to this site.