Rubyで模様生成機
ランダムで模様作るよ
前提:
gem install geo_pattern --no-ri --no-rdoc
gem install color
require 'webrick' require 'geo_pattern' random = Random.new(20) server = WEBrick::HTTPServer.new({:BindAddress => '0.0.0.0', :Port => 3000}) trap(:INT){server.shutdown} server.mount_proc('/') do |req, res| range = 0.0..1.0 col = Color::RGB.from_fraction( random.rand(range), random.rand(range), random.rand(range) ) pattern = GeoPattern.generate(col.html, patterns: :plaid, base_color: col.html) content = "<div style=\"background-image: #{pattern.to_data_uri};min-height:768px; width:1024px;\">" res.body = content res.content_length = content.size res.content_type = "text/html" end server.start