Esempio n. 1
0
        public static unsafe void Paint()
        {
            Vector2 shapeCoord = new Vector2();
            float   num        = P3D_Helper.Reciprocal(P3D_Brush.canvasW * P3D_Brush.detailScale.x);
            float   num2       = P3D_Helper.Reciprocal(P3D_Brush.canvasH * P3D_Brush.detailScale.y);
            Color * colorPtr1  = &P3D_Brush.color;

            colorPtr1->a *= P3D_Brush.opacity;
            int xMin = P3D_Brush.rect.XMin;

            while (xMin < P3D_Brush.rect.XMax)
            {
                int yMin = P3D_Brush.rect.YMin;
                while (true)
                {
                    if (yMin >= P3D_Brush.rect.YMax)
                    {
                        xMin++;
                        break;
                    }
                    if (P3D_Brush.IsInsideShape(P3D_Brush.inverse, xMin, yMin, ref shapeCoord))
                    {
                        Color pixel   = P3D_Brush.canvas.GetPixel(xMin, yMin);
                        Color color   = P3D_Brush.color;
                        float opacity = P3D_Brush.opacity;
                        if (P3D_Brush.shape != null)
                        {
                            opacity *= P3D_Brush.shape.GetPixelBilinear(shapeCoord.x, shapeCoord.y).a;
                        }
                        if (P3D_Brush.detail != null)
                        {
                            color *= P3D_Brush.SampleRepeat(P3D_Brush.detail, num * xMin, num2 * yMin);
                        }
                        P3D_Brush.canvas.SetPixel(xMin, yMin, Color.Lerp(pixel, color, opacity));
                    }
                    yMin++;
                }
            }
        }
Esempio n. 2
0
        public static unsafe void Paint()
        {
            Vector2 shapeCoord = new Vector2();
            float   num        = P3D_Helper.Reciprocal(P3D_Brush.canvasW * P3D_Brush.detailScale.x);
            float   num2       = P3D_Helper.Reciprocal(P3D_Brush.canvasH * P3D_Brush.detailScale.y);
            Color * colorPtr1  = &P3D_Brush.color;

            colorPtr1->a *= P3D_Brush.opacity;
            if ((P3D_Brush.shape != null) && (P3D_Brush.shape.format != TextureFormat.Alpha8))
            {
                int xMin = P3D_Brush.rect.XMin;
                while (xMin < P3D_Brush.rect.XMax)
                {
                    int yMin = P3D_Brush.rect.YMin;
                    while (true)
                    {
                        if (yMin >= P3D_Brush.rect.YMax)
                        {
                            xMin++;
                            break;
                        }
                        if (P3D_Brush.IsInsideShape(P3D_Brush.inverse, xMin, yMin, ref shapeCoord))
                        {
                            Vector3 a       = ColorToNormalXY(P3D_Brush.canvas.GetPixel(xMin, yMin));
                            Vector3 vector4 = ColorToNormalXY(P3D_Brush.shape.GetPixelBilinear(shapeCoord.x, shapeCoord.y));
                            if (P3D_Brush.detail != null)
                            {
                                vector4 = CombineNormalsXY(vector4, ColorToNormalXY(P3D_Brush.SampleRepeat(P3D_Brush.detail, num * xMin, num2 * yMin)));
                            }
                            P3D_Brush.canvas.SetPixel(xMin, yMin, NormalToColor(Vector3.Normalize(ComputeZ(CombineNormalsXY(a, vector4, P3D_Brush.opacity)))));
                        }
                        yMin++;
                    }
                }
            }
            else
            {
                int xMin = P3D_Brush.rect.XMin;
                while (xMin < P3D_Brush.rect.XMax)
                {
                    int yMin = P3D_Brush.rect.YMin;
                    while (true)
                    {
                        if (yMin >= P3D_Brush.rect.YMax)
                        {
                            xMin++;
                            break;
                        }
                        if (P3D_Brush.IsInsideShape(P3D_Brush.inverse, xMin, yMin, ref shapeCoord))
                        {
                            Vector3 a         = ColorToNormalXY(P3D_Brush.canvas.GetPixel(xMin, yMin));
                            Vector2 direction = P3D_Brush.direction;
                            float   opacity   = P3D_Brush.opacity;
                            if (P3D_Brush.shape != null)
                            {
                                opacity *= P3D_Brush.shape.GetPixelBilinear(shapeCoord.x, shapeCoord.y).a;
                            }
                            if (P3D_Brush.detail != null)
                            {
                                Vector3 b = ColorToNormalXY(P3D_Brush.SampleRepeat(P3D_Brush.detail, num * xMin, num2 * yMin));
                                direction = CombineNormalsXY((Vector3)direction, b);
                            }
                            P3D_Brush.canvas.SetPixel(xMin, yMin, NormalToColor(Vector3.Normalize(ComputeZ(CombineNormalsXY(a, direction, opacity)))));
                        }
                        yMin++;
                    }
                }
            }
        }