Anonymous user
Bitmap: Difference between revisions
Changed Image from object to ref object to allocate it on the heap.
(Replaced "Pixel" by "Color" and "px" by "color".) |
(Changed Image from object to ref object to allocate it on the heap.) |
||
Line 2,757:
r, g, b: Luminance
Image* = ref object
w*, h*: Index
pixels*: seq[Color]
Line 2,774:
White* = color(255, 255, 255)
proc
## Create an image with given width and height.
new(result)
result.w = width
result.h = height
Line 2,790 ⟶ 2,791:
img.pixels[y * img.w + x]
proc `[]=`*(img:
## Set a pixel RGB value to given color.
img.pixels[y * img.w + x] = c
proc fill*(img:
## Fill the image with a color.
for x, y in img.indices:
Line 2,808 ⟶ 2,809:
when isMainModule:
var img =
img.fill color(255, 255, 255)
img[1, 2] = color(255, 0, 0)
|