Пример #1
0
 public override void ClearToColor(color c)
 {
     Size2I size = Graphics.DeviceContext.SizeInPixels;
     Graphics.UseDefaultBrush();
     Graphics.SetDefaultBrushColor(GetColorref(c));
     Graphics.DeviceContext.Rectangle(0, 0, size.width, size.height);
 }
Пример #2
0
        void setGradient(int x, int y, float w, float h, color c1, color c2, int axis)
        {
            float deltaR = red(c2) - red(c1);
            float deltaG = green(c2) - green(c1);
            float deltaB = blue(c2) - blue(c1);

            // choose axis
            if (axis == Y_AXIS)
            {
                for (int i = x; i <= (x + w); i++)
                {
                    // row
                    for (int j = y; j <= (y + h); j++)
                    {
                        color c = color((int)(red(c1) + (j - y) * (deltaR / h)),
                            (int)(green(c1) + (j - y) * (deltaG / h)),
                            (int)(blue(c1) + (j - y) * (deltaB / h)));
                        
                        set(i, j, c);
                    }
                }
            }
            else if (axis == X_AXIS)
            {
                // column
                for (int i = y; i <= (y + h); i++)
                {
                    // row
                    for (int j = x; j <= (x + w); j++)
                    {
                        color c = color((int)(red(c1) + (j - x) * (deltaR / h)),
    (int)(green(c1) + (j - x) * (deltaG / h)),
    (int)(blue(c1) + (j - x) * (deltaB / h)));
                        set(j, i, c);
                    }
                }
            }
        }
Пример #3
0
 // blue
 public float blue(color c)
 {
     return c.blue;
 }
Пример #4
0
 // blendColor
 public color blendColor(color c1, color c2, BLENDMODE mode)
 {
     return new color(c1.red, c1.green, c1.blue);
 }
Пример #5
0
 // alpha
 public float alpha(color c)
 {
     return c.alpha;
 }
Пример #6
0
        public void stroke(color c)
        {
            byte red = (byte)Math.Round(lerp(0, 255, norm(c.red, 0, fColorRange.r)));
            byte green = (byte)Math.Round(lerp(0, 255, norm(c.green, 0, fColorRange.g)));
            byte blue = (byte)Math.Round(lerp(0, 255, norm(c.blue, 0, fColorRange.b)));
            byte alpha = (byte)Math.Round(lerp(0, 255, norm(c.alpha, 0, fColorRange.a)));

            color newColor = new color(red, green, blue, alpha);

            // Clamp the color to the color range
            strokeColor = newColor;
            useStroke = true;
            ResetPen();
        }
Пример #7
0
 public override void SetPixel(float x, float y, color c)
 {
     Graphics.BeginDraw();
     Graphics.DrawLine(new Point2F(x, y), new Point2F(x, y), fStrokeBrush, strokeWidth);
     Graphics.EndDraw();
 }
Пример #8
0
        // image
        // imageMode
        // loadImage
        // noTint
        // requestImage
        // tint
        #endregion Loading & Displaying

        #region Pixels
        // blend
        // copy
        // filter
        // get
        // loadPixels
        // pixels
        // set
        public void set(int x, int y, color c)
        {
            Renderer.SetPixel(x, y, c);
        }
Пример #9
0
        public void background(color c)
        {
            backgroundColor = c;
            Renderer.ClearToColor(c);

            ResetPen();
            ResetBrush();
        }
Пример #10
0
 public void background(color c, int alpha)
 {
     color newColor = new color(c.red, c.green, c.blue, (byte)alpha);
     background(newColor);
 }
Пример #11
0
        public PLang(PRenderer rndr)
        {
            colorMode(RGB, 255);

            // Stroke default
            fStrokeWeight = 1;
            fStrokeJoin = ROUND;
            fStrokeEndCap = SQUARE;
            strokeColor = new color(0, 0, 0, 255);
            useStroke = true;

            // Fill Default
            fFillColor = new color(255, 255, 255, 255);
            useFill = true;

            backgroundColor = new color(255, 255, 255, 255);

            fRectMode = CORNER;
            fEllipseMode = CENTER;

            fShapeMode = NOSHAPE;

            SetRenderer(rndr);
        }
Пример #12
0
 public abstract void SetPixel(float x, float y, color c);
Пример #13
0
 public abstract void ClearToColor(color c);
Пример #14
0
        void createGradient(float x, float y, float radius, color c1, color c2)
        {
            float px = 0;
            float py = 0;
            float angle = 0;

            // calculate differences between color components
            float deltaR = red(c2) - red(c1);
            float deltaG = green(c2) - green(c1);
            float deltaB = blue(c2) - blue(c1);

            float gapFiller = 8;

            for (int i = 0; i < radius; i++)
            {
                for (float j = 0; j < 360; j += 1.0f / gapFiller)
                {
                    px = x + cos(radians(angle)) * i;
                    py = y + sin(radians(angle)) * i;
                    angle += 1.0f / gapFiller;

                    color c = color(
                        ((int)red(c1) + (i) * (deltaR / radius)),
                        ((int)green(c1) + (i) * (deltaG / radius)),
                        ((int)blue(c1) + (i) * (deltaB / radius)));

                    set((int)px, (int)py, c);
                }
            }

            // adds smooth edges
            // hack anti-aliasing
            noFill();
            strokeWeight(3);
            ellipse(x, y, radius * 2, radius * 2);
        }
Пример #15
0
 // green
 public float green(color c)
 {
     return c.green;
 }
Пример #16
0
 public void fill(color c, int alpha)
 {
     color newColor = new color(c.red, c.green, c.blue, (byte)alpha);
     fill(c);
 }
Пример #17
0
 // hue
 // lerpColor
 
 // red
 public float red(color c)
 {
     return c.red;
 }
Пример #18
0
 public void fill(color c)
 {
     fFillColor = c;
     useFill = true;
     ResetBrush();
 }
Пример #19
0
 Colorref GetColorref(color c)
 {
     return Colorref.FromRGB(c.red, c.green, c.blue);
 }
Пример #20
0
 public void stroke(color c, int alpha)
 {
     color newColor = new color(c.red, c.green, c.blue, (byte)alpha);
     stroke(newColor);
 }
Пример #21
0
 public override void SetPixel(float x, float y, color c)
 {
     Graphics.DeviceContext.SetPixel((int)x, (int)y, GetColorref(c)); 
 }
Пример #22
0
 public override void ClearToColor(color c)
 {
 }