Exemplo n.º 1
0
    void RandomNoise(ScreenBufferState data, int numNoisePixels)
    {
        for (int i = 0; i < numNoisePixels; i++)
        {
            int x = Random.Range(0, (int)data.size.x);
            int y = Random.Range(0, (int)data.size.y);

            data.SetColorCodeAt(x, y, (ColorCode)Random.Range(0, 15));
        }
    }
Exemplo n.º 2
0
 /// Fills the buffer data with values generated by a function of pixel coordinates.
 public static void Fill(this ScreenBufferState data, Func <int, int, ColorCode> function)
 {
     for (int y = 0; y < data.size.y; ++y)
     {
         for (int x = 0; x < data.size.x; ++x)
         {
             data.SetColorCodeAt(x, y, function(x, y));
         }
     }
 }
Exemplo n.º 3
0
 /// Fills the buffer data with a specified color.
 public static void Fill(this ScreenBufferState data, ColorCode colorCode)
 {
     for (int y = 0; y < data.size.y; ++y)
     {
         for (int x = 0; x < data.size.x; ++x)
         {
             data.SetColorCodeAt(x, y, colorCode);
         }
     }
 }
Exemplo n.º 4
0
    /// <summary>
    /// Displays a character on the display. Is tied to an aligned grid 4px wide by 8px tall, per original LEM1802 spec.
    /// </summary>
    /// <remarks>
    /// This utilizes the default font set of the LEM1802; manual pixel control is available from the SetPixel call.
    /// This code presumes that a display's resolution can be evenly divided into 4px w by 8 px h cells.
    /// Original font ripped from https://rdr4g0n.github.io/0x10c_SpriteStudio/.
    /// </remarks>
    /// <param name="data">The buffer that is being manipulated.</param>
    /// <param name="x">The X coordinate of where to render the character.</param>
    /// <param name="y">The Y coordinate of where to render the character.</param>
    /// <param name="c">The 32 bits that represent pixels of the character being on or off</param>
    /// <param name="foreground">The color to use for the positive space (pixels the character fills).</param>
    /// <param name="background">The color to use for the negative space (pixels the character doesn't fill.</param>
    public static void WriteChar(this ScreenBufferState data, int x, int y, uint character, ColorCode foreground, ColorCode background)
    {
        // Filter the cell indices, and multiply the amounts by the cell sizes.
        x = (x % (data.size.x / 4)) * 4;
        y = (y % (data.size.y / 8)) * 8;

        for (int i = 31; i >= 0; i--)
        {
            int pixelX = x + (i / 8), pixelY = y + 7 - (i % 8);

            bool filled = ((character >> (31 - i)) & 1) == 1;

            data.SetColorCodeAt(pixelX, pixelY, (filled ? foreground : background));
        }
    }