GetInt() public method

Gets the color as a packed integer.
public GetInt ( ) : int
return int
Exemplo n.º 1
0
 public void SetPixel(int x, int y, ColorInstance color)
 {
     fixed (byte* buf = _pixels)
     {
         SetPixelFast(buf, x, y, color.GetInt());
     }
     _changed = true;
 }
Exemplo n.º 2
0
 public void PointSeries(ArrayInstance array, ColorInstance color)
 {
     int c = color.GetInt();
     fixed (byte* buf = _pixels)
     {
         for (var i = 0; i < array.Length; ++i)
         {
             Vector2f vect = GlobalPrimitives.GetVector(array[i] as ObjectInstance);
             SetPixelFast(buf, (int)vect.X, (int)vect.Y, c);
         }
     }
     _changed = true;
 }
Exemplo n.º 3
0
 public void Rectangle(int ox, int oy, int w, int h, ColorInstance color)
 {
     h = Math.Max(0, Math.Min(h + oy, _height));
     w = Math.Max(0, Math.Min(w + ox, _width));
     int c = color.GetInt();
     int hh = h * _width;
     int yy = oy * _width;
     fixed (byte* buf = _pixels)
     {
         for (; yy < hh; yy += _width)
             for (int x = ox; x < w; ++x)
                 SetPixelFast(buf, x + yy, c, _mode);
     }
     _changed = true;
 }
Exemplo n.º 4
0
        public void OutlinedCircle(int ox, int oy, int r, ColorInstance color, [DefaultParameterValue(false)] bool antialias = false)
        {
            if (r < 0 || color == null || ox < 0 || oy < 0)
                throw new ArgumentException("Invalid parameters.");
            else if (r == 0)
                return;

            fixed (byte* buf = _pixels)
            {
                var w = r * 2;
                var h = w;
                var c = color.GetColor();

                if (antialias)
                {
                    var pio2 = Math.PI / 2;
                    for (var y = 0; y < r; ++y)
                    {
                        for (var x = 0; x < r; ++x)
                        {
                            var dist = Math.Sqrt(x * x + y * y);
                            if (dist > r - 2 && dist < r)
                            {
                                c.A = (byte)(c.A * Math.Sin(Math.Sin((1 - Math.Abs(dist - r + 1)) * pio2) * pio2));
                                SetPixel(buf, ox + x + r, oy + y + r, ref c);
                                SetPixel(buf, ox + r - x, oy + y + r, ref c);
                                SetPixel(buf, ox + r - x, oy + r - y, ref c);
                                SetPixel(buf, ox + x + r, oy + r - y, ref c);
                            }
                        }
                    }
                }
                else
                {
                    var pi2 = Math.PI * 2;
                    var step = pi2 / (Math.Min(360, pi2 * r));
                    int ci = color.GetInt();
                    for (double pt = 0.0, pt2 = step; pt < pi2; pt += step, pt2 += step)
                    {
                        int x1 = (int)(r + r * Math.Sin(pt));
                        int y1 = (int)(r + r * Math.Cos(pt));
                        int x2 = (int)(r + r * Math.Sin(pt2));
                        int y2 = (int)(r + r * Math.Cos(pt2));
                        Line(buf, ox + x1, oy + y1, ox + x2, oy + y2, ci);
                    }
                }
            }
            _changed = true;
        }
Exemplo n.º 5
0
 public void OutlinedRectangle(int x, int y, int w, int h, ColorInstance color)
 {
     int c = color.GetInt();
     fixed (byte* buf = _pixels)
     {
         Line(buf, x, y, x + w, y, c);
         Line(buf, x + w, y, x + w, y + h, c);
         Line(buf, x + w, y + h, x, y + h, c);
         Line(buf, x, y, x, y + h, c);
     }
     _changed = true;
 }
Exemplo n.º 6
0
 public void LineSeries(ArrayInstance points, ColorInstance color)
 {
     int c = color.GetInt();
     fixed (byte* buf = _pixels)
     {
         for (var i = 1; i < points.Length; i += 2)
         {
             Vector2f start = GlobalPrimitives.GetVector(points[i - 1] as ObjectInstance);
             Vector2f end = GlobalPrimitives.GetVector(points[i] as ObjectInstance);
             Line(buf, (int)start.X, (int)start.Y, (int)end.X, (int)end.Y, c);
         }
     }
     _changed = true;
 }
Exemplo n.º 7
0
 public void Line(int x1, int y1, int x2, int y2, ColorInstance color)
 {
     int col = color.GetInt();
     fixed (byte* buf = _pixels)
     {
         Line(buf, x1, y1, x2, y2, col);
     }
     _changed = true;
 }
Exemplo n.º 8
0
        public void GradientRectangle(int ox, int oy, int w, int h, ColorInstance col1, ColorInstance col2, ColorInstance col3, ColorInstance col4)
        {
            h = Math.Max(0, Math.Min(h + oy, (int)_height));
            w = Math.Max(0, Math.Min(w + ox, (int)_width));
            int c1 = col1.GetInt(), c2 = col2.GetInt();
            int c3 = col3.GetInt(), c4 = col4.GetInt();

            fixed (byte* buf = _pixels)
            {
                for (int y = 0; y < h; ++y)
                {
                    float weight = (float)y / h;
                    int w1 = FastBlend(c1, c4, weight);
                    int w2 = FastBlend(c2, c3, weight);
                    for (int x = 0; x < w; ++x)
                    {
                        int c = FastBlend(w1, w2, (float)x / w);
                        SetPixelFast(buf, ox + x, oy + y, c);
                    }
                }
            }
            _changed = true;
        }
Exemplo n.º 9
0
 public void GradientLine(int x1, int y1, int x2, int y2, ColorInstance col1, ColorInstance col2)
 {
     fixed (byte* buf = _pixels)
     {
         GradientLine(buf, x1, y1, x2, y2, col1.GetInt(), col2.GetInt());
     }
     _changed = true;
 }
Exemplo n.º 10
0
        public void FilledCircle(int ox, int oy, int r, ColorInstance color, [DefaultParameterValue(false)] bool antialias = false)
        {
            if (ox < 0 || oy < 0 || r < 0 || color == null)
                throw new ArgumentException("Invalid parameters.");
            if (r == 0)
                return;

            fixed (byte* buf = _pixels)
            {

                var pi2 = Math.PI / 2;
                var w = r * 2;
                var h = w;
                Color c = color.GetColor();
                ox -= r;
                oy -= r;

                if (antialias)
                {
                    for (var y = 0; y < r; ++y)
                    {
                        for (var x = 0; x < r; ++x)
                        {
                            var dist = Math.Sqrt(x * x + y * y);
                            if (dist < r)
                            {
                                if (dist > r - 1)
                                    c.A = (byte)(c.A * Math.Sin(Math.Sin((r - dist) * pi2) * pi2));
                                SetPixel(buf, ox + x + r, oy + y + r, ref c);
                                SetPixel(buf, ox + r - x, oy + y + r, ref c);
                                SetPixel(buf, ox + r - x, oy + r - y, ref c);
                                SetPixel(buf, ox + x + r, oy + r - y, ref c);
                            }
                        }
                    }
                }
                else
                {
                    int ci = color.GetInt();
                    for (var y = 0; y < r; ++y)
                    {
                        int lw = (int)(r * Math.Cos(Math.Asin(1 - (float)y / r)));
                        Line(buf, ox + r - lw, oy + y, ox + r + lw, oy + y, ci);
                        Line(buf, ox + r - lw, oy + h - y - 1, ox + r + lw, oy + h - y - 1, ci);
                    }
                }
            }
            _changed = true;
        }