Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,13 @@
|
|||
require "./pixmap"
|
||||
|
||||
class Pixmap
|
||||
def write_ppm (io)
|
||||
io.print "P6\n# Visit Rosetta code!\n#{width} #{height}\n255\n"
|
||||
@data.each do |c|
|
||||
io.write_byte c.r
|
||||
io.write_byte c.g
|
||||
io.write_byte c.b
|
||||
end
|
||||
end
|
||||
register_writer ".ppm", write_ppm
|
||||
end
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
require "./write_ppm"
|
||||
|
||||
img = Pixmap.new 3, 2, Color::WHITE
|
||||
|
||||
[[0xFF0000, 0x00FF00, 0x0000FF],
|
||||
[0xFFFF00, 0x00FFFF, 0xFF00FF]].each_with_index do |row, y|
|
||||
row.each_with_index do |color, x|
|
||||
img[x, y] = Color.new color
|
||||
end
|
||||
end
|
||||
|
||||
img.write "mini.ppm"
|
||||
|
||||
File.read("mini.ppm").unsafe_byte_slice(0).hexdump(STDOUT)
|
||||
Loading…
Add table
Add a link
Reference in a new issue