fix coordinates calculation of pixels

This commit is contained in:
Gwenhael Le Moine 2023-07-25 15:50:13 +02:00
parent e60b310585
commit a194565a1d
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -89,7 +89,7 @@ module Types
@height.times do |y|
@width.times do |x|
canvas[x, y] = @bits[ ( y * @height ) + x ] == 1
canvas[x, y] = @bits[ ( y * @width ) + x ] == 1
end
end
@ -97,11 +97,11 @@ module Types
end
def get_pixel( pos_x, pos_y )
@bits[ ( pos_y * @height ) + pos_x ]
@bits[ ( pos_y * @width ) + pos_x ]
end
def set_pixel( pos_x, pos_y, value )
@bits[ ( pos_y * @height ) + pos_x ] = value.to_i.zero? ? 0 : 1
@bits[ ( pos_y * @width ) + pos_x ] = value.to_i.zero? ? 0 : 1
end
def clear