Bitmap/Bresenham's line algorithm: Difference between revisions

Content added Content deleted
(add Ruby)
m (→‎{{header|Ruby}}: update example)
Line 837: Line 837:
end
end


bitmap = Pixmap.new(30, 30)
bitmap = Pixmap.new(500, 500)
bitmap.draw_line(Pixel[0,0], Pixel[14,29], RGBColour::BLACK)
bitmap.fill(RGBColour::BLUE)
10.step(430, 60) do |a|
bitmap.draw_line(Pixel[0,0], Pixel[29,14], RGBColour::BLACK)
bitmap.draw_line(Pixel[0,29], Pixel[14,0], RGBColour::BLACK)
bitmap.draw_line(Pixel[10, 10], Pixel[490,a], RGBColour::YELLOW)
bitmap.draw_line(Pixel[0,29], Pixel[29,14], RGBColour::BLACK)</lang>
bitmap.draw_line(Pixel[10, 10], Pixel[a,490], RGBColour::YELLOW)
end
bitmap.draw_line(Pixel[10, 10], Pixel[490,490], RGBColour::YELLOW)</lang>


=={{header|Tcl}}==
=={{header|Tcl}}==