mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-02-02 20:45:54 +01:00
26 lines
629 B
Crystal
26 lines
629 B
Crystal
|
module PF
|
||
|
class Sprite
|
||
|
# Draw a single point
|
||
|
def draw_point(x : Int32, y : Int32, color : UInt32)
|
||
|
if x >= 0 && x < width && y >= 0 && y < height
|
||
|
pixel_pointer(x, y).value = color
|
||
|
end
|
||
|
end
|
||
|
|
||
|
# ditto
|
||
|
def draw_point(x : Int32, y : Int32, pixel : Pixel = Pixel.new)
|
||
|
draw_point(x, y, pixel.format(format))
|
||
|
end
|
||
|
|
||
|
# ditto
|
||
|
def draw_point(point : Vector(Int, 2), pixel : Pixel = Pixel.new)
|
||
|
draw_point(point.x, point.y, pixel)
|
||
|
end
|
||
|
|
||
|
# ditto
|
||
|
def draw_point(point : Vector(Float, 2), pixel : Pixel = Pixel.new)
|
||
|
draw_point(point.to_i32, pixel)
|
||
|
end
|
||
|
end
|
||
|
end
|