about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/config.nim8
-rw-r--r--src/css/values.nim6
-rw-r--r--src/html/dom.nim10
-rw-r--r--src/img/bitmap.nim10
-rw-r--r--src/img/painter.nim22
-rw-r--r--src/img/png.nim10
-rw-r--r--src/io/bufreader.nim4
-rw-r--r--src/io/bufwriter.nim4
-rw-r--r--src/layout/renderdocument.nim4
-rw-r--r--src/types/color.nim98
10 files changed, 88 insertions, 88 deletions
diff --git a/src/config/config.nim b/src/config/config.nim
index 6611b4ef..81630f07 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -110,7 +110,7 @@ type
     image_mode* {.jsgetset.}: Option[ImageMode]
     emulate_overline* {.jsgetset.}: bool
     alt_screen* {.jsgetset.}: Option[bool]
-    highlight_color* {.jsgetset.}: RGBAColor
+    highlight_color* {.jsgetset.}: ARGBColor
     highlight_marks* {.jsgetset.}: bool
     double_width_ambiguous* {.jsgetset.}: bool
     minimum_contrast* {.jsgetset.}: int32
@@ -315,7 +315,7 @@ proc parseConfigValue(ctx: var ConfigParser; x: var Option[FormatMode];
   v: TomlValue; k: string)
 proc parseConfigValue(ctx: var ConfigParser; x: var FormatMode; v: TomlValue;
   k: string)
-proc parseConfigValue(ctx: var ConfigParser; x: var RGBAColor; v: TomlValue;
+proc parseConfigValue(ctx: var ConfigParser; x: var ARGBColor; v: TomlValue;
   k: string)
 proc parseConfigValue(ctx: var ConfigParser; x: var RGBColor; v: TomlValue;
   k: string)
@@ -486,10 +486,10 @@ proc parseConfigValue(ctx: var ConfigParser; x: var FormatMode; v: TomlValue;
       raise newException(ValueError, "unknown format mode '" & vv.s &
         "' for key " & kk)
 
-proc parseConfigValue(ctx: var ConfigParser; x: var RGBAColor; v: TomlValue;
+proc parseConfigValue(ctx: var ConfigParser; x: var ARGBColor; v: TomlValue;
     k: string) =
   typeCheck(v, tvtString, k)
-  let c = parseRGBAColor(v.s)
+  let c = parseARGBColor(v.s)
   if c.isNone:
     raise newException(ValueError, "invalid color '" & v.s &
       "' for key " & k)
diff --git a/src/css/values.nim b/src/css/values.nim
index 647e3d67..1a373ae1 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -575,7 +575,7 @@ func quoteEnd*(level: int): string =
     return "“"
   return "‘"
 
-const Colors: Table[string, RGBAColor] = ((func (): Table[string, RGBAColor] =
+const Colors: Table[string, ARGBColor] = ((func (): Table[string, ARGBColor] =
   for name, rgb in ColorsRGB:
     result[name] = rgb
   result["transparent"] = rgba(0x00, 0x00, 0x00, 0x00)
@@ -636,7 +636,7 @@ func skipWhitespace(vals: openArray[CSSComponentValue]; i: var int) =
       break
     inc i
 
-func parseRGBA(value: openArray[CSSComponentValue]): Opt[CellColor] =
+func parseARGB(value: openArray[CSSComponentValue]): Opt[CellColor] =
   var i = 0
   var commaMode = false
   template check_err(slash: bool) =
@@ -735,7 +735,7 @@ func cssColor*(val: CSSComponentValue): Opt[CellColor] =
   elif val of CSSFunction:
     let f = CSSFunction(val)
     if f.name.equalsIgnoreCase("rgb") or f.name.equalsIgnoreCase("rgba"):
-      return parseRGBA(f.value)
+      return parseARGB(f.value)
     elif f.name.equalsIgnoreCase("-cha-ansi"):
       return parseANSI(f.value)
   return err()
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 76ed9b70..0c009b6b 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -326,8 +326,8 @@ type
     # CanvasTransform
     transformMatrix: Matrix
     # CanvasFillStrokeStyles
-    fillStyle: RGBAColor
-    strokeStyle: RGBAColor
+    fillStyle: ARGBColor
+    strokeStyle: ARGBColor
     # CanvasPathDrawingStyles
     lineWidth: float64
     # CanvasTextDrawingStyles
@@ -424,7 +424,7 @@ jsDestructor(CanvasRenderingContext2D)
 jsDestructor(TextMetrics)
 jsDestructor(CSSStyleDeclaration)
 
-proc parseColor(element: Element; s: string): RGBAColor
+proc parseColor(element: Element; s: string): ARGBColor
 
 proc resetTransform(state: var DrawingState) =
   state.transformMatrix = newIdentityMatrix(3)
@@ -2344,7 +2344,7 @@ isDefaultPassive = func (eventTarget: EventTarget): bool =
     EventTarget(node.document.html) == eventTarget or
     EventTarget(node.document.body) == eventTarget
 
-proc parseColor(element: Element; s: string): RGBAColor =
+proc parseColor(element: Element; s: string): ARGBColor =
   let cval = parseComponentValue(newStringStream(s))
   #TODO return element style
   # For now we just use white.
@@ -2357,7 +2357,7 @@ proc parseColor(element: Element; s: string): RGBAColor =
   let color = color0.get
   if color.t != ctRGB:
     return ec
-  return color.rgbacolor
+  return color.argbcolor
 
 #TODO ??
 func target0*(element: Element): string =
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()
diff --git a/src/io/bufreader.nim b/src/io/bufreader.nim
index 3ee36208..f25309e2 100644
--- a/src/io/bufreader.nim
+++ b/src/io/bufreader.nim
@@ -54,7 +54,7 @@ proc sread*(reader: var BufferedReader; part: var FormDataEntry)
 proc sread*(reader: var BufferedReader; blob: var Blob)
 proc sread*[T](reader: var BufferedReader; o: var Option[T])
 proc sread*[T, E](reader: var BufferedReader; o: var Result[T, E])
-proc sread*(reader: var BufferedReader; c: var RGBAColor) {.inline.}
+proc sread*(reader: var BufferedReader; c: var ARGBColor) {.inline.}
 
 proc readData(reader: var BufferedReader; buffer: pointer; len: int) =
   assert reader.bufIdx + len <= reader.buffer.len
@@ -201,5 +201,5 @@ proc sread*[T, E](reader: var BufferedReader; o: var Result[T, E]) =
     else:
       o.err()
 
-proc sread*(reader: var BufferedReader; c: var RGBAColor) =
+proc sread*(reader: var BufferedReader; c: var ARGBColor) =
   reader.sread(uint32(c))
diff --git a/src/io/bufwriter.nim b/src/io/bufwriter.nim
index 0957d3e8..509f2907 100644
--- a/src/io/bufwriter.nim
+++ b/src/io/bufwriter.nim
@@ -77,7 +77,7 @@ proc swrite*(writer: var BufferedWriter; part: FormDataEntry)
 proc swrite*(writer: var BufferedWriter; blob: Blob)
 proc swrite*[T](writer: var BufferedWriter; o: Option[T])
 proc swrite*[T, E](writer: var BufferedWriter; o: Result[T, E])
-proc swrite*(writer: var BufferedWriter; c: RGBAColor) {.inline.}
+proc swrite*(writer: var BufferedWriter; c: ARGBColor) {.inline.}
 
 proc writeData(writer: var BufferedWriter; buffer: pointer; len: int) =
   let targetLen = writer.bufLen + len
@@ -183,5 +183,5 @@ proc swrite*[T, E](writer: var BufferedWriter; o: Result[T, E]) =
     when not (E is void):
       writer.swrite(o.error)
 
-proc swrite*(writer: var BufferedWriter; c: RGBAColor) =
+proc swrite*(writer: var BufferedWriter; c: ARGBColor) =
   writer.swrite(uint32(c))
diff --git a/src/layout/renderdocument.nim b/src/layout/renderdocument.nim
index e57a6d2c..b2e896fe 100644
--- a/src/layout/renderdocument.nim
+++ b/src/layout/renderdocument.nim
@@ -352,7 +352,7 @@ proc renderInlineFragment(grid: var FlexibleGrid; state: var RenderState;
     fragment: InlineFragment; offset: Offset) =
   assert fragment.atoms.len == 0 or fragment.children.len == 0
   let bgcolor = fragment.computed{"background-color"}
-  if bgcolor.t == ctANSI or bgcolor.t == ctRGB and bgcolor.rgbacolor.a > 0:
+  if bgcolor.t == ctANSI or bgcolor.t == ctRGB and bgcolor.argbcolor.a > 0:
     #TODO color blending
     grid.paintInlineFragment(state, fragment, offset, bgcolor)
   if fragment.atoms.len > 0:
@@ -421,7 +421,7 @@ proc renderBlockBox(grid: var FlexibleGrid; state: var RenderState;
 
     if box.computed{"visibility"} == VisibilityVisible:
       let bgcolor = box.computed{"background-color"}
-      if bgcolor.t == ctANSI or bgcolor.t == ctRGB and bgcolor.rgbacolor.a > 0:
+      if bgcolor.t == ctANSI or bgcolor.t == ctRGB and bgcolor.argbcolor.a > 0:
         if box.computed{"-cha-bgcolor-is-canvas"} and
             state.bgcolor == defaultColor:
           #TODO bgimage
diff --git a/src/types/color.nim b/src/types/color.nim
index 922201da..74a305b8 100644
--- a/src/types/color.nim
+++ b/src/types/color.nim
@@ -13,7 +13,7 @@ type
   RGBColor* = distinct uint32
 
   # RGBA color, stored in ARGB format
-  RGBAColor* = distinct uint32
+  ARGBColor* = distinct uint32
 
   ANSIColor* = distinct uint8
 
@@ -22,20 +22,20 @@ type
   # ctNone: default color (intentionally 0), n is unused
   # ctANSI: ANSI color, as selected by SGR 38/48
   # ctRGB: RGB color
-  ColorTag* {.size: sizeof(uint32).} = enum
+  ColorTag* = enum
     ctNone, ctANSI, ctRGB
 
   CellColor* = object
     t*: ColorTag
     n: uint32
 
-func toRGBColor*(i: RGBAColor): RGBColor =
+func toRGBColor*(i: ARGBColor): RGBColor =
   return RGBColor(uint32(i) and 0xFFFFFFu32)
 
-converter toRGBAColor*(i: RGBColor): RGBAColor =
-  return RGBAColor(uint32(i) or 0xFF000000u32)
+converter toARGBColor*(i: RGBColor): ARGBColor =
+  return ARGBColor(uint32(i) or 0xFF000000u32)
 
-func `==`*(a, b: RGBAColor): bool {.borrow.}
+func `==`*(a, b: ARGBColor): bool {.borrow.}
 
 func `==`*(a, b: ANSIColor): bool {.borrow.}
 
@@ -44,8 +44,8 @@ func `==`*(a, b: EightBitColor): bool {.borrow.}
 func rgbcolor*(color: CellColor): RGBColor =
   cast[RGBColor](color.n)
 
-func rgbacolor*(color: CellColor): RGBAColor =
-  cast[RGBAColor](color.n)
+func argbcolor*(color: CellColor): ARGBColor =
+  cast[ARGBColor](color.n)
 
 func color*(color: CellColor): uint8 =
   uint8(color.n)
@@ -56,7 +56,7 @@ func eightbit*(color: CellColor): EightBitColor =
 func cellColor*(rgb: RGBColor): CellColor =
   return CellColor(t: ctRGB, n: uint32(rgb) or 0xFF000000u32)
 
-func cellColor*(rgba: RGBAColor): CellColor =
+func cellColor*(rgba: ARGBColor): CellColor =
   return CellColor(t: ctRGB, n: uint32(rgba))
 
 #TODO bright ANSI colors (8..15)
@@ -235,32 +235,32 @@ const ColorsRGB* = block:
     res[it[0]] = RGBColor(it[1])
   res
 
-func r*(c: RGBAColor): uint8 =
+func r*(c: ARGBColor): uint8 =
   return uint8(uint32(c) shr 16)
 
-func g*(c: RGBAColor): uint8 =
+func g*(c: ARGBColor): uint8 =
   return uint8(uint32(c) shr 8)
 
-func b*(c: RGBAColor): uint8 =
+func b*(c: ARGBColor): uint8 =
   return uint8(uint32(c))
 
-func a*(c: RGBAColor): uint8 =
+func a*(c: ARGBColor): uint8 =
   return uint8(uint32(c) shr 24)
 
-proc `r=`*(c: var RGBAColor, r: uint8) =
-  c = RGBAColor(uint32(c) or (uint32(r) shl 16))
+proc `r=`*(c: var ARGBColor, r: uint8) =
+  c = ARGBColor(uint32(c) or (uint32(r) shl 16))
 
-proc `g=`*(c: var RGBAColor, g: uint8) =
-  c = RGBAColor(uint32(c) or (uint32(g) shl 8))
+proc `g=`*(c: var ARGBColor, g: uint8) =
+  c = ARGBColor(uint32(c) or (uint32(g) shl 8))
 
-proc `b=`*(c: var RGBAColor, b: uint8) =
-  c = RGBAColor(uint32(c) or uint32(b))
+proc `b=`*(c: var ARGBColor, b: uint8) =
+  c = ARGBColor(uint32(c) or uint32(b))
 
-proc `a=`*(c: var RGBAColor, a: uint8) =
-  c = RGBAColor(uint32(c) or (uint32(a) shl 24))
+proc `a=`*(c: var ARGBColor, a: uint8) =
+  c = ARGBColor(uint32(c) or (uint32(a) shl 24))
 
 # https://html.spec.whatwg.org/#serialisation-of-a-color
-func serialize*(color: RGBAColor): string =
+func serialize*(color: ARGBColor): string =
   if color.a == 255:
     var res = "#"
     res.pushHex(color.r)
@@ -271,8 +271,8 @@ func serialize*(color: RGBAColor): string =
   return "rgba(" & $color.r & ", " & $color.g & ", " & $color.b & ", " & $a &
     ")"
 
-func `$`*(rgbacolor: RGBAColor): string =
-  return rgbacolor.serialize()
+func `$`*(argbcolor: ARGBColor): string =
+  return argbcolor.serialize()
 
 # https://arxiv.org/pdf/2202.02864.pdf
 func fastmul*(c, ca: uint32): uint32 =
@@ -304,27 +304,27 @@ func fastmul1(c, ca: uint32): uint32 =
   ga = ga and 0xFF00FF00u32
   return ga or (rb shr 8)
 
-func fastmul1(c: RGBAColor; ca: uint32): RGBAColor =
-  return RGBAColor(fastmul1(uint32(c), ca))
+func fastmul1(c: ARGBColor; ca: uint32): ARGBColor =
+  return ARGBColor(fastmul1(uint32(c), ca))
 
-func rgba*(r, g, b, a: uint8): RGBAColor
+func rgba*(r, g, b, a: uint8): ARGBColor
 
-func premul(c: RGBAColor): RGBAColor =
-  return RGBAColor(fastmul(uint32(c), uint32(c.a)))
+func premul(c: ARGBColor): ARGBColor =
+  return ARGBColor(fastmul(uint32(c), uint32(c.a)))
 
 # This is somewhat faster than floats or a lookup table, and is correct for
 # all inputs.
-proc straight(c: RGBAColor): RGBAColor =
+proc straight(c: ARGBColor): ARGBColor =
   let a8 = c.a
   if a8 == 0:
-    return RGBAColor(0)
+    return ARGBColor(0)
   let a = uint32(a8)
   let r = ((uint32(c.r) * 0xFF00 div a + 0x80) shr 8) and 0xFF
   let g = ((uint32(c.g) * 0xFF00 div a + 0x80) shr 8) and 0xFF
   let b = ((uint32(c.b) * 0xFF00 div a + 0x80) shr 8) and 0xFF
-  return RGBAColor((a shl 24) or (r shl 16) or (g shl 8) or b)
+  return ARGBColor((a shl 24) or (r shl 16) or (g shl 8) or b)
 
-func blend*(c0, c1: RGBAColor): RGBAColor =
+func blend*(c0, c1: ARGBColor): ARGBColor =
   let pc0 = c0.premul()
   let pc1 = c1.premul()
   let k = 255 - pc1.a
@@ -377,11 +377,11 @@ func YUV*(Y, U, V: uint8): RGBColor =
   let b = max(min((298 * C + 516 * D + 128) shr 8, 255), 0)
   return rgb(uint8(r), uint8(g), uint8(b))
 
-func rgba*(r, g, b, a: uint8): RGBAColor =
-  return RGBAColor((uint32(a) shl 24) or (uint32(r) shl 16) or
+func rgba*(r, g, b, a: uint8): ARGBColor =
+  return ARGBColor((uint32(a) shl 24) or (uint32(r) shl 16) or
     (uint32(g) shl 8) or uint32(b))
 
-func rgba*(r, g, b, a: int): RGBAColor =
+func rgba*(r, g, b, a: int): ARGBColor =
   return rgba(uint8(r), uint8(g), uint8(b), uint8(a))
 
 func gray*(n: uint8): RGBColor =
@@ -425,43 +425,43 @@ template `$`*(rgbcolor: RGBColor): string =
 
 template `$`*(color: CellColor): string =
   if color.t == ctRGB:
-    $color.rgbacolor
+    $color.argbcolor
   else:
     "tcolor" & $color.n
 
-func parseHexColor*(s: string): Option[RGBAColor] =
+func parseHexColor*(s: string): Option[ARGBColor] =
   for c in s:
-    if hexValue(c) == -1: return none(RGBAColor)
+    if hexValue(c) == -1: return none(ARGBColor)
   case s.len
   of 6:
     let c = 0xFF000000 or
             (hexValue(s[0]) shl 20) or (hexValue(s[1]) shl 16) or
             (hexValue(s[2]) shl 12) or (hexValue(s[3]) shl 8) or
             (hexValue(s[4]) shl 4) or hexValue(s[5])
-    return some(RGBAColor(c))
+    return some(ARGBColor(c))
   of 8:
     let c = (hexValue(s[6]) shl 28) or (hexValue(s[7]) shl 24) or
             (hexValue(s[0]) shl 20) or (hexValue(s[1]) shl 16) or
             (hexValue(s[2]) shl 12) or (hexValue(s[3]) shl 8) or
             (hexValue(s[4]) shl 4) or hexValue(s[5])
-    return some(RGBAColor(c))
+    return some(ARGBColor(c))
   of 3:
     let c = 0xFF000000 or
             (hexValue(s[0]) shl 20) or (hexValue(s[0]) shl 16) or
             (hexValue(s[1]) shl 12) or (hexValue(s[1]) shl 8) or
             (hexValue(s[2]) shl 4) or hexValue(s[2])
-    return some(RGBAColor(c))
+    return some(ARGBColor(c))
   of 4:
     let c = (hexValue(s[3]) shl 28) or (hexValue(s[3]) shl 24) or
             (hexValue(s[0]) shl 20) or (hexValue(s[0]) shl 16) or
             (hexValue(s[1]) shl 12) or (hexValue(s[1]) shl 8) or
             (hexValue(s[2]) shl 4) or hexValue(s[2])
-    return some(RGBAColor(c))
+    return some(ARGBColor(c))
   else: discard
 
-func parseRGBAColor*(s: string): Option[RGBAColor] =
+func parseARGBColor*(s: string): Option[ARGBColor] =
   if s in ColorsRGB:
-    return some(RGBAColor(ColorsRGB[s]))
+    return some(ARGBColor(ColorsRGB[s]))
   if (s.len == 3 or s.len == 4 or s.len == 6 or s.len == 8) and s[0] == '#':
     return parseHexColor(s[1..^1])
   if s.len > 2 and s[0] == '0' and s[1] == 'x':
@@ -522,7 +522,7 @@ proc toJS*(ctx: JSContext; rgb: RGBColor): JSValue =
 proc fromJSRGBColor*(ctx: JSContext; val: JSValue): JSResult[RGBColor] =
   return parseLegacyColor(?fromJS[string](ctx, val))
 
-proc toJS*(ctx: JSContext; rgba: RGBAColor): JSValue =
+proc toJS*(ctx: JSContext; rgba: ARGBColor): JSValue =
   var res = "#"
   res.pushHex(rgba.r)
   res.pushHex(rgba.g)
@@ -530,12 +530,12 @@ proc toJS*(ctx: JSContext; rgba: RGBAColor): JSValue =
   res.pushHex(rgba.a)
   return toJS(ctx, res)
 
-proc fromJSRGBAColor*(ctx: JSContext; val: JSValue): JSResult[RGBAColor] =
+proc fromJSARGBColor*(ctx: JSContext; val: JSValue): JSResult[ARGBColor] =
   if JS_IsNumber(val):
     # as hex
-    return ok(RGBAColor(?fromJS[uint32](ctx, val)))
+    return ok(ARGBColor(?fromJS[uint32](ctx, val)))
   # parse
-  let x = parseRGBAColor(?fromJS[string](ctx, val))
+  let x = parseARGBColor(?fromJS[string](ctx, val))
   if x.isSome:
     return ok(x.get)
   return errTypeError("Unrecognized color")