Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,17 @@
|
|||
require "./pixmap"
|
||||
|
||||
class Pixmap
|
||||
def line (x0, y0, x1, y1, color)
|
||||
dx, sx = (x1-x0).abs, x0<x1 ? 1 : -1
|
||||
dy, sy = (y1-y0).abs, y0<y1 ? 1 : -1
|
||||
err = (dx>dy ? dx : -dy) // 2
|
||||
|
||||
loop do
|
||||
self[x0, y0] = color
|
||||
break if x0 == x1 && y0 == y1
|
||||
e2 = err
|
||||
(err -= dy; x0 += sx) if e2 >-dx
|
||||
(err += dx; y0 += sy) if e2 < dy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
require "./bresenham"
|
||||
|
||||
img = Pixmap.new 10, 5, Color::WHITE
|
||||
|
||||
img.line 0, 3, 9, 0, Color::RED
|
||||
|
||||
img.write STDOUT
|
||||
Loading…
Add table
Add a link
Reference in a new issue