about summary refs log tree commit diff stats
path: root/src/img
diff options
context:
space:
mode:
Diffstat (limited to 'src/img')
-rw-r--r--src/img/bitmap.nim10
-rw-r--r--src/img/painter.nim22
-rw-r--r--src/img/png.nim10
3 files changed, 21 insertions, 21 deletions
diff --git a/src/img/bitmap.nim b/src/img/bitmap.nim
index 76d36747..9f9b3401 100644
--- a/src/img/bitmap.nim
+++ b/src/img/bitmap.nim
@@ -2,7 +2,7 @@ import types/color
 
 type
   Bitmap* = ref object of RootObj
-    px*: seq[RGBAColor]
+    px*: seq[ARGBColor]
     width*: uint64
     height*: uint64
 
@@ -10,18 +10,18 @@ type
 
 proc newBitmap*(width, height: uint64): Bitmap =
   return ImageBitmap(
-    px: newSeq[RGBAColor](width * height),
+    px: newSeq[ARGBColor](width * height),
     width: width,
     height: height
   )
 
-proc setpx*(bmp: Bitmap; x, y: uint64; color: RGBAColor) {.inline.} =
+proc setpx*(bmp: Bitmap; x, y: uint64; color: ARGBColor) {.inline.} =
   bmp.px[bmp.width * y + x] = color
 
-proc getpx*(bmp: Bitmap; x, y: uint64): RGBAColor {.inline.} =
+proc getpx*(bmp: Bitmap; x, y: uint64): ARGBColor {.inline.} =
   return bmp.px[bmp.width * y + x]
 
-proc setpxb*(bmp: Bitmap; x, y: uint64; color: RGBAColor) {.inline.} =
+proc setpxb*(bmp: Bitmap; x, y: uint64; color: ARGBColor) {.inline.} =
   if color.a == 255:
     bmp.setpx(x, y, color)
   else:
diff --git a/src/img/painter.nim b/src/img/painter.nim
index 53841a14..090f690e 100644
--- a/src/img/painter.nim
+++ b/src/img/painter.nim
@@ -14,7 +14,7 @@ type CanvasFillRule* = enum
   cfrEvenOdd = "evenodd"
 
 # https://en.wikipedia.org/wiki/Bresenham's_line_algorithm#All_cases
-proc plotLineLow(bmp: Bitmap; x0, y0, x1, y1: int64; color: RGBAColor) =
+proc plotLineLow(bmp: Bitmap; x0, y0, x1, y1: int64; color: ARGBColor) =
   var dx = x1 - x0
   var dy = y1 - y0
   var yi = 1
@@ -32,7 +32,7 @@ proc plotLineLow(bmp: Bitmap; x0, y0, x1, y1: int64; color: RGBAColor) =
        D = D - 2 * dx;
     D = D + 2 * dy;
 
-proc plotLineHigh(bmp: Bitmap; x0, y0, x1, y1: int64; color: RGBAColor) =
+proc plotLineHigh(bmp: Bitmap; x0, y0, x1, y1: int64; color: ARGBColor) =
   var dx = x1 - x0
   var dy = y1 - y0
   var xi = 1
@@ -51,7 +51,7 @@ proc plotLineHigh(bmp: Bitmap; x0, y0, x1, y1: int64; color: RGBAColor) =
     D = D + 2 * dx
 
 #TODO should be uint64...
-proc plotLine(bmp: Bitmap; x0, y0, x1, y1: int64; color: RGBAColor) =
+proc plotLine(bmp: Bitmap; x0, y0, x1, y1: int64; color: ARGBColor) =
   if abs(y1 - y0) < abs(x1 - x0):
     if x0 > x1:
       bmp.plotLineLow(x1, y1, x0, y0, color)
@@ -63,13 +63,13 @@ proc plotLine(bmp: Bitmap; x0, y0, x1, y1: int64; color: RGBAColor) =
     else:
       bmp.plotLineHigh(x0, y0, x1, y1, color)
 
-proc plotLine(bmp: Bitmap; a, b: Vector2D; color: RGBAColor) =
+proc plotLine(bmp: Bitmap; a, b: Vector2D; color: ARGBColor) =
   bmp.plotLine(int64(a.x), int64(a.y), int64(b.x), int64(b.y), color)
 
-proc plotLine(bmp: Bitmap; line: Line; color: RGBAColor) =
+proc plotLine(bmp: Bitmap; line: Line; color: ARGBColor) =
   bmp.plotLine(line.p0, line.p1, color)
 
-proc strokePath*(bmp: Bitmap; path: Path; color: RGBAColor) =
+proc strokePath*(bmp: Bitmap; path: Path; color: ARGBColor) =
   for line in path.lines:
     bmp.plotLine(line, color)
 
@@ -79,7 +79,7 @@ func isInside(windingNumber: int; fillRule: CanvasFillRule): bool =
   of cfrEvenOdd: windingNumber mod 2 == 0
 
 # Mainly adapted from SerenityOS.
-proc fillPath*(bmp: Bitmap; path: Path; color: RGBAColor;
+proc fillPath*(bmp: Bitmap; path: Path; color: ARGBColor;
     fillRule: CanvasFillRule) =
   let lines = path.getLineSegments()
   var i = 0
@@ -118,12 +118,12 @@ proc fillPath*(bmp: Bitmap; path: Path; color: RGBAColor;
     if ylines.len > 0:
       ylines[^1].minyx += ylines[^1].islope
 
-proc fillRect*(bmp: Bitmap; x0, x1, y0, y1: uint64, color: RGBAColor) =
+proc fillRect*(bmp: Bitmap; x0, x1, y0, y1: uint64, color: ARGBColor) =
   for y in y0 ..< y1:
     for x in x0 ..< x1:
       bmp.setpxb(x, y, color)
 
-proc strokeRect*(bmp: Bitmap; x0, x1, y0, y1: uint64, color: RGBAColor) =
+proc strokeRect*(bmp: Bitmap; x0, x1, y0, y1: uint64, color: ARGBColor) =
   for x in x0 ..< x1:
     bmp.setpxb(x, y0, color)
     bmp.setpxb(x, y1, color)
@@ -186,7 +186,7 @@ proc drawBitmap(a, b: Bitmap; p: Vector2D) =
       if ax >= 0 and ay >= y and ax < a.width and ay < a.height:
         a.setpxb(ax, ay, b.getpx(x, y))
 
-proc fillText*(bmp: Bitmap; text: string; x, y: float64; color: RGBAColor;
+proc fillText*(bmp: Bitmap; text: string; x, y: float64; color: ARGBColor;
     textAlign: CSSTextAlign) =
   var w = 0f64
   var glyphs: seq[Bitmap]
@@ -205,7 +205,7 @@ proc fillText*(bmp: Bitmap; text: string; x, y: float64; color: RGBAColor;
     bmp.drawBitmap(glyph, Vector2D(x: x, y: y - 8))
     x += float64(glyph.width)
 
-proc strokeText*(bmp: Bitmap; text: string; x, y: float64; color: RGBAColor;
+proc strokeText*(bmp: Bitmap; text: string; x, y: float64; color: ARGBColor;
     textAlign: CSSTextAlign) =
   #TODO
   bmp.fillText(text, x, y, color, textAlign)
diff --git a/src/img/png.nim b/src/img/png.nim
index 0b486f23..1e75121b 100644
--- a/src/img/png.nim
+++ b/src/img/png.nim
@@ -106,7 +106,7 @@ type PNGReader = object
   i: int
   bitDepth: uint8
   colorType: PNGColorType
-  background: RGBAColor
+  background: ARGBColor
   isend: bool
   idatBuf: seq[uint8]
   uprow: seq[uint8]
@@ -116,8 +116,8 @@ type PNGReader = object
   strmend: bool
   atline: int
   plteseen: bool
-  palette: seq[RGBAColor]
-  trns: RGBAColor
+  palette: seq[ARGBColor]
+  trns: ARGBColor
 
 func width(reader: PNGReader): int {.inline.} = int(reader.bmp.width)
 
@@ -307,7 +307,7 @@ proc unfilter(reader: var PNGReader; irow: openArray[uint8]; bpp: int) =
   else:
     reader.err "got invalid filter"
 
-proc writepxs(reader: var PNGReader; crow: var openArray[RGBAColor]) =
+proc writepxs(reader: var PNGReader; crow: var openArray[ARGBColor]) =
   case reader.colorType
   of pcGrayscale:
     var i = 0
@@ -387,7 +387,7 @@ proc readPLTE(reader: var PNGReader) =
   let len = reader.limit - reader.i
   if len mod 3 != 0:
     reader.err "palette length not divisible by 3"
-  reader.palette = newSeq[RGBAColor](len)
+  reader.palette = newSeq[ARGBColor](len)
   for i in 0 ..< len div 3:
     let r = reader.readU8()
     let g = reader.readU8()