Example #1
0
    public void Erase(IBrushDrawable drawable, int brushX, int brushY)
    {
        for (int by = 0; by < Size; by++)
        {
            for (int bx = 0; bx < Size; bx++)
            {
                int fx = brushX + bx;
                int fy = brushY + by;
                if (drawable.IsDrawable(fx, fy))
                {
                    int index      = fx + (fy * drawable.Width);
                    int brushIndex = (int)(bx + by * Size);

                    drawable.Colors[index].a = Mathf.Clamp01(drawable.Colors[index].a - Alphas[brushIndex]);
                }
            }
        }
    }
Example #2
0
    public void DrawLine(IBrushDrawable drawable, int fromX, int fromY, int toX, int toY, UnityEngine.Color color)
    {
        var distanceX = (float)Mathf.Abs(fromX - toX);
        var distanceY = (float)Mathf.Abs(fromY - toY);

        float stepX      = 0f;
        float stepY      = 0f;
        int   iterations = 0;

        if (distanceX > distanceY)
        {
            iterations = (int)distanceX;
            if (iterations > 0)
            {
                stepX = fromX < toX ? 1f : -1f;
                stepY = (toY - fromY) / distanceX;
            }
        }
        else
        {
            iterations = (int)distanceY;
            if (iterations > 0)
            {
                stepX = (toX - fromX) / distanceY;
                stepY = fromY < toY ? 1f : -1f;
            }
        }

        float lx = fromX;
        float ly = fromY;

        for (int li = 0; li < iterations; li++)
        {
            Draw(drawable, (int)Mathf.RoundToInt(lx), (int)Mathf.RoundToInt(ly), color);
            ly += stepY;
            lx += stepX;
        }
        Draw(drawable, (int)(toX), (int)(toY), color);
    }
Example #3
0
    public void Draw(IBrushDrawable drawable, int brushX, int brushY, UnityEngine.Color color)
    {
        for (int by = 0; by < Size; by++)
        {
            for (int bx = 0; bx < Size; bx++)
            {
                int fx = brushX + bx;
                int fy = brushY + by;

                if (drawable.IsDrawable(fx, fy))
                {
                    int index      = fx + (fy * drawable.Width);
                    int brushIndex = (int)(bx + by * Size);

                    UnityEngine.Color A = color;
                    A.a *= Alphas[brushIndex];

                    drawable.Colors[index] = drawable.Colors[index].AlphaComposite(A);
                }
            }
        }
    }
Example #4
0
 public void Erase(IBrushDrawable drawable, int brushX, int brushY)
 {
     drawable.Bitmap.Subtract(BrushTexture, new TextureBitmap.Color(0, 0, 0, 255), new TextureBitmap.Point(brushX, brushY), null, drawable.IsDrawable);
 }
Example #5
0
 public void Draw(IBrushDrawable drawable, int brushX, int brushY, UnityEngine.Color color)
 {
     drawable.Bitmap.AlphaComposite(BrushTexture, new TextureBitmap.Color((byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), (byte)(color.a * 255f)), new TextureBitmap.Point(brushX, brushY), null, drawable.IsDrawable);
 }