public RenderOptions(EgaColor defaultFgColor = EgaColor.Black, EgaColor defaultBgColor = EgaColor.White) { DefaultBackgroundColor = defaultBgColor; DefaultForegroundColor = defaultFgColor; BackgroundColor = defaultBgColor; ForegroundColor = defaultFgColor; }
public void SetsBackgroundColor(string argument, EgaColor expected) { var entry = new Background(new List <Flag>(), new List <Argument> { new Argument(null, argument) }); var ctx = new EntryRenderContext(null, null, new RenderOptions()); entry.Evaluate(ctx); Assert.AreEqual(expected, ctx.Options.BackgroundColor); }
public Color(EgaColor c) => _color = c;
protected void RenderLine(SpriteRenderContext renderContext, byte[] frameBuffer, int pixelOffset, int x1, int y1, int x2, int y2, EgaColor color = EgaColor.Black) { int w = x2 - x1; int h = y2 - y1; int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0; if (w < 0) { dx1 = -1; } else if (w > 0) { dx1 = 1; } if (h < 0) { dy1 = -1; } else if (h > 0) { dy1 = 1; } if (w < 0) { dx2 = -1; } else if (w > 0) { dx2 = 1; } int longest = Math.Abs(w); int shortest = Math.Abs(h); if (!(longest > shortest)) { longest = Math.Abs(h); shortest = Math.Abs(w); if (h < 0) { dy2 = -1; } else if (h > 0) { dy2 = 1; } dx2 = 0; } int numerator = longest >> 1; for (int i = 0; i <= longest; i++) { // putpixel(x, y, color); if ((y1 * renderContext.State.Width) + x1 + pixelOffset < 0) { continue; } frameBuffer[(y1 * renderContext.State.Width) + x1 + pixelOffset] = (byte)color; numerator += shortest; if (!(numerator < longest)) { numerator -= longest; x1 += dx1; y1 += dy1; } else { x1 += dx2; y1 += dy2; } } }
public CombinedColor(EgaColor background, EgaColor foreground) { Value = (byte)((((byte)foreground & 0x0F) << 4) | ((byte)background & 0x0F)); }