예제 #1
0
            public override void Draw(ref Bitmap bitmap, PlotProperties plotprops)
            {
                double theta_degree = theta * 180 / Math.PI;
                double SF           = ImageUtil.CalculateScaleFactor(bitmap, plotprops);

                int _b1 = (int)(b1 * SF);
                int _b2 = (int)(b2 * SF);
                int _t  = (int)(t * SF);
                int _r  = (int)(r * SF);
                int _R  = (_r + _t);

                if (_r < 1)
                {
                    _r = 1;
                }                      //_r must be at least one pixel
                if (_R < 1)
                {
                    _R = 1;
                }                      //_R must also be at least one pixel (not an issue as long as t isn't super small)

                int wdth = bitmap.Width;
                int hght = bitmap.Height;

                Graphics g = Graphics.FromImage(bitmap);

                GraphicsPath path = new GraphicsPath();

                path.AddLine(0, _R, 0, _b2);
                path.AddLine(0, _b2, _t, _b2);
                path.AddLine(_t, _b2, _t, _t + _r);
                path.AddArc(new System.Drawing.Rectangle(_t, _t, 2 * _r, 2 * _r), 180, 90);
                path.AddLine(_t + _r, _t, _b1, _t);
                path.AddLine(_b1, _t, _b1, 0);
                path.AddLine(_b1, 0, _R, 0);
                path.AddArc(new System.Drawing.Rectangle(0, 0, 2 * _R, 2 * _R), 270, -90);
                path.CloseFigure();

                PointF pnt = CreateImagePoint(SF);

                Coordinate xy_min = ImageUtil.CalculateImageXYmin(bitmap, plotprops);

                double Xdel = xp - xy_min.x;
                double Ydel = yp - xy_min.y;

                Matrix mtrx = ImageUtil.ImageTransformationMatrix(bitmap, pnt, theta_degree, Xdel, Ydel, SF, mirrorX, mirrorY);

                path.Transform(mtrx);

                Color _fillColor = Material.ConvertFillColor();

                Pen _pen = new Pen(borderColor, borderThickness);

                _pen.Alignment = PenAlignment.Inset;
                g.FillPath(new SolidBrush(_fillColor), path);
                g.DrawPath(_pen, path);

                _pen.Dispose();
                g.Dispose();
            }
예제 #2
0
            private double _R; //outer radius

            public override void Draw(ref Bitmap bitmap, PlotProperties plotprops)
            {
                double theta_degree = theta * 180 / Math.PI;
                double SF           = ImageUtil.CalculateScaleFactor(bitmap, plotprops);

                int int_r     = (int)(r * SF);
                int int_R     = (int)(_R * SF);
                int int_t     = (int)(t * SF);
                int deg_alpha = (int)(alpha * 180 / Math.PI);

                double cos = (Math.Cos(alpha));
                double sin = (Math.Sin(alpha));


                int wdth = bitmap.Width;
                int hght = bitmap.Height;

                Graphics g = Graphics.FromImage(bitmap);

                GraphicsPath path = new GraphicsPath();

                path.AddLine((int)(int_r * cos), (int)(int_r * sin), (int)(int_R * cos), (int)(int_R * sin));
                path.AddArc(new System.Drawing.Rectangle(-int_R, -int_R, 2 * int_R, 2 * int_R), deg_alpha, -2 * deg_alpha);
                path.AddLine((int)(int_R * cos), (int)(-int_R * sin), (int)(int_r * cos), (int)(-int_r * sin));
                path.AddArc(new System.Drawing.Rectangle(-int_r, -int_r, 2 * int_r, 2 * int_r), -deg_alpha, 2 * deg_alpha);
                path.CloseFigure();

                PointF pnt = CreateImagePoint(SF);

                Coordinate xy_min = ImageUtil.CalculateImageXYmin(bitmap, plotprops);

                double Xdel = xp - xy_min.x;
                double Ydel = yp - xy_min.y;

                Matrix mtrx = ImageUtil.ImageTransformationMatrix(bitmap, pnt, theta_degree, Xdel, Ydel, SF, mirrorX, mirrorY);

                path.Transform(mtrx);

                Color _fillColor = Material.ConvertFillColor();

                Pen _pen = new Pen(borderColor, borderThickness);

                _pen.Alignment = PenAlignment.Inset;
                g.FillPath(new SolidBrush(_fillColor), path);
                g.DrawPath(_pen, path);

                _pen.Dispose();
                g.Dispose();
            }
예제 #3
0
            public override void Draw(ref Bitmap bitmap, PlotProperties plotprops)
            {
                double theta_degree = theta * 180 / Math.PI;
                double SF           = ImageUtil.CalculateScaleFactor(bitmap, plotprops);

                int _r = (int)(r * SF);

                if (_r <= 2)
                {
                    //throws error if shape doesn't take up enough pixels
                    return;
                }

                int wdth = bitmap.Width;
                int hght = bitmap.Height;

                Graphics g = Graphics.FromImage(bitmap);

                GraphicsPath path = new GraphicsPath();

                path.AddLine(0, 0, 0, _r);
                path.AddArc(new System.Drawing.Rectangle(0, 0, 2 * _r, 2 * _r), 180, 90);
                path.AddLine(_r, 0, 0, 0);
                path.CloseFigure();

                PointF pnt = CreateImagePoint(SF);

                Coordinate xy_min = ImageUtil.CalculateImageXYmin(bitmap, plotprops);

                double Xdel = xp - xy_min.x;
                double Ydel = yp - xy_min.y;

                Matrix mtrx = ImageUtil.ImageTransformationMatrix(bitmap, pnt, theta_degree, Xdel, Ydel, SF, mirrorX, mirrorY);

                path.Transform(mtrx);

                Color _fillColor = Material.ConvertFillColor();

                Pen _pen = new Pen(borderColor, borderThickness);

                _pen.Alignment = PenAlignment.Inset;
                g.FillPath(new SolidBrush(_fillColor), path);
                g.DrawPath(_pen, path);

                _pen.Dispose();
                g.Dispose();
            }
예제 #4
0
            public override void Draw(ref Bitmap bitmap, PlotProperties plotprops)
            {
                double theta_degree = theta * 180 / Math.PI;
                double SF           = ImageUtil.CalculateScaleFactor(bitmap, plotprops);

                float _b = (float)(b * SF);
                float _t = (float)(t * SF);

                int wdth = bitmap.Width;
                int hght = bitmap.Height;

                Graphics g = Graphics.FromImage(bitmap);

                GraphicsPath path = new GraphicsPath();

                path.AddLine(0, 0, 0, _t);
                path.AddLine(0, _t, _b, _t);
                path.AddLine(_b, _t, _b, 0);
                path.AddLine(_b, 0, 0, 0);
                path.CloseFigure();

                PointF pnt = CreateImagePoint(SF);

                Coordinate xy_min = ImageUtil.CalculateImageXYmin(bitmap, plotprops);

                double Xdel = xp - xy_min.x;
                double Ydel = yp - xy_min.y;

                Matrix mtrx = ImageUtil.ImageTransformationMatrix(bitmap, pnt, theta_degree, Xdel, Ydel, SF, mirrorX, mirrorY);

                path.Transform(mtrx);

                Color _fillColor = Material.ConvertFillColor();

                Pen _pen = new Pen(borderColor, borderThickness);

                _pen.Alignment = PenAlignment.Inset;
                g.FillPath(new SolidBrush(_fillColor), path);
                g.DrawPath(_pen, path);

                _pen.Dispose();
                g.Dispose();
            }
예제 #5
0
            public override void Draw(ref Bitmap bitmap, PlotProperties plotprops)
            {
                double theta_degree = theta * 180 / Math.PI;
                double SF           = ImageUtil.CalculateScaleFactor(bitmap, plotprops);

                int _b1 = (int)(b1 * SF);
                int _t1 = (int)(t1 * SF);
                int _b2 = (int)(b2 * SF);
                int _t2 = (int)(t2 * SF);
                int _r1 = (int)(r1 * SF);
                int _r2 = (int)(r2 * SF);
                int _h  = (int)(h * SF);
                int _tw = (int)(tw * SF);

                int wdth = bitmap.Width;
                int hght = bitmap.Height;

                if (_r1 < 1)
                {
                    _r1 = 1;
                }
                if (_r2 < 1)
                {
                    _r2 = 1;
                }

                Graphics g = Graphics.FromImage(bitmap);

                GraphicsPath path = new GraphicsPath();

                path.AddLine(0, 0, 0, _h - _t2 - _r2);
                path.AddArc(new System.Drawing.Rectangle(-_r2 * 2, _h - _t2 - _r2 * 2, _r2 * 2, _r2 * 2), 0, 90);
                path.AddLine(-_r2, _h - _t2, -_b2 + _tw, _h - _t2);
                path.AddLine(-_b2 + _tw, _h - _t2, -_b2 + _tw, _h);
                path.AddLine(-_b2 + _tw, _h, _tw, _h);
                path.AddLine(_tw, _h, _tw, _t1 + _r1);
                path.AddArc(new System.Drawing.Rectangle(_tw, _t1, _r1 * 2, _r1 * 2), 180, 90);
                path.AddLine(_tw + _r1, _t1, _b1, _t1);
                path.AddLine(_b1, _t1, _b1, 0);
                path.AddLine(_b1, 0, 0, 0);
                path.CloseFigure();

                PointF pnt = CreateImagePoint(SF);

                Coordinate xy_min = ImageUtil.CalculateImageXYmin(bitmap, plotprops);

                double Xdel = xp - xy_min.x;
                double Ydel = yp - xy_min.y;

                Matrix mtrx = ImageUtil.ImageTransformationMatrix(bitmap, pnt, theta_degree, Xdel, Ydel, SF, mirrorX, mirrorY);

                path.Transform(mtrx);

                Color _fillColor = Material.ConvertFillColor();

                Pen _pen = new Pen(borderColor, borderThickness);

                _pen.Alignment = PenAlignment.Inset;
                g.FillPath(new SolidBrush(_fillColor), path);
                g.DrawPath(_pen, path);

                _pen.Dispose();
                g.Dispose();
            }