Exemple #1
0
		public GetPixelSection()
		{
			var location = new Point(100, 100);
			var image = TestIcons.Textures;
			var drawable = new BufferedDrawable { EnableDoubleBuffering = true };
			this.Content = drawable;

			EventHandler<MouseEventArgs> mouseHandler = (s, e) =>
			{
				location = new Point(e.Location);
				((Control)s).Invalidate();
				e.Handled = true;
			};

			drawable.MouseMove += mouseHandler;
			drawable.MouseDown += mouseHandler;

			var font = SystemFonts.Default();
			drawable.BackgroundColor = Colors.Green;
			drawable.Paint += (s, e) =>
			{
				var graphics = e.Graphics;
				var imageLocation = new PointF(100, 100);
				graphics.DrawText(font, Colors.White, 3, 3, "Move the mouse in this area to read the pixel color.");
				graphics.DrawImage(image, imageLocation);

				var loc = location - (Point)imageLocation;
				loc.Restrict(new Rectangle(image.Size));
				var pixelColor = image.GetPixel(loc.X, loc.Y);
				graphics.DrawText(font, Colors.White, 3, 20, "Color: " + pixelColor);
			};
		}
Exemple #2
0
		public BrushSection()
		{
			var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) };

			// defaults
			ScaleX = 100f;
			ScaleY = 100f;
			Center = new PointF(100, 50);
			GradientOrigin = new PointF(150, 80);
			Radius = new SizeF(100f, 50f);
			StartPoint = new PointF(50, 50);
			EndPoint = new PointF(100, 100);

			drawable = new Drawable { Size = new Size(450, 400) };

			drawable.Paint += (sender, pe) => Draw(pe.Graphics);

			layout.AddSeparateRow(null, BrushControl(), UseBackgroundColorControl(), null);
			if (Platform.Supports<NumericUpDown>())
			{
				matrixRow = layout.AddSeparateRow(null, new Label { Text = "Rot" }, RotationControl(), new Label { Text = "Sx" }, ScaleXControl(), new Label { Text = "Sy" }, ScaleYControl(), new Label { Text = "Ox" }, OffsetXControl(), new Label { Text = "Oy" }, OffsetYControl(), null);
				matrixRow.Table.Visible = false;
			}
			gradientRow = layout.AddSeparateRow(null, GradientWrapControl(), null);
			gradientRow.Table.Visible = false;
			radialRow = layout.AddSeparateRow(null, "Center:", CenterControl(), "GradientOrigin:", GradientOriginControl(), null);
			radiusRow = layout.AddSeparateRow(null, "Radius:", RadiusControl(), null);
			linearRow = layout.AddSeparateRow(null, "Start:", StartPointControl(), "End:", EndPointControl(), null);
			layout.AddSeparateRow(null, drawable, null);
			layout.Add(null);

			this.Content = layout;
		}
Exemple #3
0
		public RectangleF(PointF start, PointF end)
		{
			this.x = start.X;
			this.y = start.Y;
			this.width = (end.X >= start.X) ? end.X - start.X + 1 : end.X - start.X;
			this.height = (end.Y >= start.Y) ? end.Y - start.Y + 1: end.Y - start.Y;
		}
		public object Create (Color startColor, Color endColor, PointF startPoint, PointF endPoint)
		{
			return new swm.LinearGradientBrush (startColor.ToWpf (), endColor.ToWpf (), startPoint.ToWpf (), endPoint.ToWpf ()) {
				MappingMode = swm.BrushMappingMode.Absolute,
				SpreadMethod = swm.GradientSpreadMethod.Repeat
			};
		}
Exemple #5
0
		public RectangleF(PointF point, SizeF size)
		{
			this.x = point.X;
			this.y = point.Y;
			this.width = size.Width;
			this.height = size.Height;
		}
			public EtoGradient(PointF origin, PointF center, SizeF radius)
				: base(origin.X, origin.Y, 0, center.X, origin.Y - (origin.Y - center.Y) / (radius.Height / radius.Width), radius.Width)
			{
				
				Center = center;
				GradientOrigin = origin;
				Radius = radius;
			}
Exemple #7
0
		public MouseEventArgs(MouseButtons buttons, Keys modifiers, PointF location, SizeF? delta = null)
		{
			this.Modifiers = modifiers;
			this.Buttons = buttons;
			this.Location = location;
			this.Pressure = 1.0f;
			this.Delta = delta ?? SizeF.Empty;
		}
		public object Create (Color startColor, Color endColor, PointF startPoint, PointF endPoint)
		{
			var gradient = new EtoGradient (startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
			gradient.Extend = Cairo.Extend.Pad;
			gradient.AddColorStop (0, startColor.ToCairo ());
			gradient.AddColorStop (1, endColor.ToCairo ());
			return gradient;
		}
		public object Create(Color startColor, Color endColor, PointF center, PointF gradientOrigin, SizeF radius)
		{
			var gradient = new EtoGradient(gradientOrigin, center, radius);
			gradient.Radius = radius;
			gradient.Extend = Cairo.Extend.Pad;
			gradient.AddColorStop(0, startColor.ToCairo());
			gradient.AddColorStop(1, endColor.ToCairo());
			return gradient;
		}
 public void AddLine(PointF point1, PointF point2)
 {
     sink.AddLines(
         new s.DrawingPointF[]
         {
             point1.ToWpf(),
             point2.ToWpf()                   
         });
 }
			public bool SetStart (PointF point)
			{
				First = false;
				if (ForceConnect) {
					ConnectTo (point);
					return false;
				}
				return true;
			}
			public void ConnectTo (PointF point)
			{
				if (First) {
					Context.MoveTo (point.X, point.Y);
					First = false;
				} else
					Context.LineTo (point.X, point.Y);
				ForceConnect = false;
			}
		public void AddLines (IEnumerable<PointF> points)
		{
			var pointsList = points as IList<PointF> ?? points.ToArray ();
			ConnectTo (pointsList.First ().ToWpf ());

			var wpfPoints = from p in pointsList select p.ToWpf ();
			figure.Segments.Add (new swm.PolyLineSegment (wpfPoints, true));
			CurrentPoint = pointsList.Last ();
		}
		public object Create (Color startColor, Color endColor, PointF startPoint, PointF endPoint)
		{
			var gradient = new EtoGradient (startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
			cairo_pattern_set_extend (gradient.Pointer, Cairo.Extend.Repeat);
			// not in windows?? gradient.Extend = Cairo.Extend.Repeat;
			gradient.AddColorStop (0, startColor.ToCairo ());
			gradient.AddColorStop (1, endColor.ToCairo ());
			return gradient;
		}
		public object Create(Color startColor, Color endColor, PointF startPoint, PointF endPoint)
		{
			return new LinearBrushData
			{
				StartColor = startColor,
				EndColor = endColor,
				StartPoint = startPoint,
				EndPoint = endPoint
			};
		}
			public Box (Size canvasSize, bool useTexturesAndGradients)
			{
				var size = new SizeF(random.Next (50) + 50, random.Next (50) + 50);
				var location = new PointF(random.Next (canvasSize.Width - (int)size.Width), random.Next (canvasSize.Height - (int)size.Height));
				position = new RectangleF(location, size);
				increment = new SizeF (random.Next (3) + 1, random.Next (3) + 1);
				if (random.Next (2) == 1)
					increment.Width = -increment.Width;
				if (random.Next (2) == 1)
					increment.Height = -increment.Height;

				angle = random.Next (360);
				rotation = (random.Next (20) - 10f) / 4f;

				var rect = new RectangleF (size);
				color = GetRandomColor (random);
				switch (random.Next (useTexturesAndGradients ? 4 : 2)) {
				case 0:
					draw = (g) => g.DrawRectangle (color, rect);
					erase = (g) => g.DrawRectangle (Colors.Black, rect);
					break;
				case 1:
					draw = (g) => g.DrawEllipse (color, rect);
					erase = (g) => g.DrawEllipse (Colors.Black, rect);
					break;
				case 2:
					switch (random.Next (2)) {
					case 0:
						fillBrush = new LinearGradientBrush (GetRandomColor (random), GetRandomColor (random), PointF.Empty, new PointF(size.Width, size.Height));
						break;
					case 1:
						fillBrush = new TextureBrush(texture) {
							Transform = Matrix.FromScale (size / 80)
						};
						break;
					}
					draw = (g) => g.FillEllipse (fillBrush, rect);
					erase = (g) => g.FillEllipse (Colors.Black, rect);
					break;
				case 3:
					switch (random.Next (2)) {
					case 0:
						fillBrush = new LinearGradientBrush (GetRandomColor (random), GetRandomColor (random), PointF.Empty, new PointF(size.Width, size.Height));
						break;
					case 1:
						fillBrush = new TextureBrush(texture) {
							Transform = Matrix.FromScale (size / 80)
						};
						break;
					}
					draw = (g) => g.FillRectangle (fillBrush, rect);
					erase = (g) => g.FillRectangle (Colors.Black, rect);
					break;
				}
			}
		public object Create(Color startColor, Color endColor, PointF center, PointF gradientOrigin, SizeF radius)
		{
			return new RadialBrushData
			{
				StartColor = startColor,
				EndColor = endColor,
				Center = center,
				GradientOrigin = gradientOrigin,
				Radius = radius
			};
		}
        public PointF ToPictureBoxCoordinate(PointF point)
        {
            var scaleX = (float)imageBounds.Width / image.Width;
            var scaleY = (float)imageBounds.Height / image.Height;

            return new PointF
            {
                X = point.X * scaleX + imageBounds.X,
                Y = point.Y * scaleY + imageBounds.Y
            };
        }
        public PointF ToImageCoordinate(PointF point)
        {
            var scaleX = (float)imageBounds.Width / image.Width;
            var scaleY = (float)imageBounds.Height / image.Height;

            return new PointF
            {
                X = (point.X - imageBounds.X) / scaleX,
                Y = (point.Y - imageBounds.Y) / scaleY
            };
        }
		public object Create(Color startColor, Color endColor, PointF center, PointF gradientOrigin, SizeF radius)
		{
			return new swm.RadialGradientBrush(startColor.ToWpf(), endColor.ToWpf())
			{
				Center = center.ToWpf(),
				GradientOrigin = gradientOrigin.ToWpf(),
				RadiusX = radius.Width,
				RadiusY = radius.Height,
				MappingMode = swm.BrushMappingMode.Absolute,
				SpreadMethod = swm.GradientSpreadMethod.Pad
			};
		}
        public void AddBezier(PointF pt1, PointF pt2, PointF pt3, PointF pt4)
        {
            sink.AddLine(pt1.ToWpf());

            sink.AddBezier(
                new sd.BezierSegment
                {
                    Point1 = pt2.ToWpf(),
                    Point2 = pt3.ToWpf(),
                    Point3 = pt4.ToWpf()
                });
        }
Exemple #22
0
        public static Eto.Drawing.Point LogicalToScreen(this Eto.Drawing.PointF point)
        {
            var screen       = Eto.Forms.Screen.FromPoint(point);
            var sdscreen     = ScreenHandler.GetControl(screen);
            var pixelSize    = sdscreen.GetLogicalPixelSize();
            var location     = sdscreen.GetBounds().Location;
            var screenBounds = screen.Bounds;

            var x = location.X + (point.X - screenBounds.X) * pixelSize;
            var y = location.Y + (point.Y - screenBounds.Y) * pixelSize;

            return(Drawing.Point.Round(new Drawing.PointF(x, y)));
        }
		public TextureBrushesSection2()
		{
			var w = image.Size.Width / 3; // same as height
			var img = image.Clone(new Rectangle(w, w, w, w));
			var brush = new TextureBrush(img);
			var drawable = new Drawable();
			var font = new Font(SystemFont.Default);
			this.Content = drawable;
			var location = new PointF(100, 100);
			drawable.BackgroundColor = Colors.Green;
			drawable.MouseMove += (s, e) => {
				location = e.Location;
				drawable.Invalidate(); };
			drawable.Paint += (s, e) => {
				e.Graphics.DrawText(font, Colors.White, 3, 3, "Move the mouse in this area to move the image.");

				var temp = brush.Transform; // save state					
				brush.Transform = Matrix.FromTranslation(location);
				e.Graphics.FillRectangle(brush, new RectangleF(location, img.Size));
				brush.Transform = temp;
			};
		}
Exemple #24
0
		static PointF[] CalculateSplineCurve (PointF point0, PointF point1, PointF point2, PointF point3, float tension, int numberOfPoints = 20)
		{
			var points = new PointF[numberOfPoints];
			float SX1 = tension * (point2.X - point0.X);
			float SY1 = tension * (point2.Y - point0.Y);
			float SX2 = tension * (point3.X - point1.X);
			float SY2 = tension * (point3.Y - point1.Y);
			float AX = SX1 + SX2 + 2 * point1.X - 2 * point2.X;
			float AY = SY1 + SY2 + 2 * point1.Y - 2 * point2.Y;
			float BX = -2 * SX1 - SX2 - 3 * point1.X + 3 * point2.X;
			float BY = -2 * SY1 - SY2 - 3 * point1.Y + 3 * point2.Y;
			float CX = SX1;
			float CY = SY1;
			float DX = point1.X;
			float DY = point1.Y;

			for (int i = 0; i < points.Length; i++) {
				float t = (float)i / (points.Length - 1);
				points[i].X = (float)(AX * t * t * t + BX * t * t + CX * t + DX);
				points[i].Y = (float)(AY * t * t * t + BY * t * t + CY * t + DY);
			}

			return points;
		}
Exemple #25
0
 public Eto.Drawing.PointF PointToScreen(Eto.Drawing.PointF point)
 {
     throw new NotImplementedException();
 }
Exemple #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Drawing.RadialGradientBrush"/>.
 /// </summary>
 /// <param name="startColor">Start color from the <paramref name="gradientOrigin"/></param>
 /// <param name="endColor">End color at the outer edge of the ellipse</param>
 /// <param name="center">Center of the ellipse</param>
 /// <param name="gradientOrigin">Origin of the gradient.</param>
 /// <param name="radius">Radius of the ellipse.</param>
 public RadialGradientBrush(Color startColor, Color endColor, PointF center, PointF gradientOrigin, SizeF radius)
 {
     handler       = Platform.Instance.CreateShared <IHandler>();
     ControlObject = handler.Create(startColor, endColor, center, gradientOrigin, radius);
 }
		#pragma warning disable 612,618

		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class between two points
		/// </summary>
		/// <param name="startColor">Start color for the gradient</param>
		/// <param name="endColor">End color for the gradient</param>
		/// <param name="startPoint">Start point for the gradient</param>
		/// <param name="endPoint">End point for the gradient</param>
		/// <param name="generator">Generator to create the brush, or null to use the current generator</param>
		public LinearGradientBrush(Color startColor, Color endColor, PointF startPoint, PointF endPoint, Generator generator)
		{
			handler = generator.CreateShared<IHandler>();
			ControlObject = handler.Create(startColor, endColor, startPoint, endPoint);
		}
Exemple #28
0
 public void Create(PointF point1, PointF point2, Color color1, Color color2)
 {
     throw new NotImplementedException();
 }
Exemple #29
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="stroke"></param>
        /// <param name="rect"></param>
        /// <param name="offsetX"></param>
        /// <param name="offsetY"></param>
        /// <param name="cellWidth"></param>
        /// <param name="cellHeight"></param>
        /// <param name="isStroked"></param>
        private void DrawGridInternal(
            Graphics gfx,
            Pen stroke,
            ref Rect2 rect,
            double offsetX, double offsetY,
            double cellWidth, double cellHeight,
            bool isStroked)
        {
            double ox = rect.X;
            double oy = rect.Y;
            double sx = ox + offsetX;
            double sy = oy + offsetY;
            double ex = ox + rect.Width;
            double ey = oy + rect.Height;

            for (double x = sx; x < ex; x += cellWidth)
            {
                var p0 = new PointF(
                    _scaleToPage(x),
                    _scaleToPage(oy));
                var p1 = new PointF(
                    _scaleToPage(x),
                    _scaleToPage(ey));
                DrawLineInternal(gfx, stroke, isStroked, ref p0, ref p1);
            }

            for (double y = sy; y < ey; y += cellHeight)
            {
                var p0 = new PointF(
                    _scaleToPage(ox),
                    _scaleToPage(y));
                var p1 = new PointF(
                    _scaleToPage(ex),
                    _scaleToPage(y));
                DrawLineInternal(gfx, stroke, isStroked, ref p0, ref p1);
            }
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class between two points
		/// </summary>
		/// <param name="startColor">Start color for the gradient</param>
		/// <param name="endColor">End color for the gradient</param>
		/// <param name="startPoint">Start point for the gradient</param>
		/// <param name="endPoint">End point for the gradient</param>
		public LinearGradientBrush(Color startColor, Color endColor, PointF startPoint, PointF endPoint)
		{
			handler = Platform.Instance.CreateShared<IHandler> ();
			ControlObject = handler.Create (startColor, endColor, startPoint, endPoint);
		}
Exemple #31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="line"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, XLine line, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var _gfx = gfx as Graphics;

            Brush fillLine = ToSolidBrush(line.Style.Fill);
            Pen strokeLine = ToPen(line.Style, _scaleToPage);

            Brush fillStartArrow = ToSolidBrush(line.Style.StartArrowStyle.Fill);
            Pen strokeStartArrow = ToPen(line.Style.StartArrowStyle, _scaleToPage);

            Brush fillEndArrow = ToSolidBrush(line.Style.EndArrowStyle.Fill);
            Pen strokeEndArrow = ToPen(line.Style.EndArrowStyle, _scaleToPage);

            double _x1 = line.Start.X + dx;
            double _y1 = line.Start.Y + dy;
            double _x2 = line.End.X + dx;
            double _y2 = line.End.Y + dy;

            XLine.SetMaxLength(line, ref _x1, ref _y1, ref _x2, ref _y2);

            float x1 = _scaleToPage(_x1);
            float y1 = _scaleToPage(_y1);
            float x2 = _scaleToPage(_x2);
            float y2 = _scaleToPage(_y2);

            var sas = line.Style.StartArrowStyle;
            var eas = line.Style.EndArrowStyle;
            float a1 = (float)(Math.Atan2(y1 - y2, x1 - x2) * 180.0 / Math.PI);
            float a2 = (float)(Math.Atan2(y2 - y1, x2 - x1) * 180.0 / Math.PI);

            var t1 = Matrix.Create();
            var c1 = new PointF(x1, y1);
            t1.RotateAt(a1, c1);

            var t2 = Matrix.Create();
            var c2 = new PointF(x2, y2);
            t2.RotateAt(a2, c2);

            PointF pt1;
            PointF pt2;

            double radiusX1 = sas.RadiusX;
            double radiusY1 = sas.RadiusY;
            double sizeX1 = 2.0 * radiusX1;
            double sizeY1 = 2.0 * radiusY1;

            switch (sas.ArrowType)
            {
                default:
                case ArrowType.None:
                    {
                        pt1 = new PointF(x1, y1);
                    }
                    break;
                case ArrowType.Rectangle:
                    {
                        pt1 = t1.TransformPoint(new PointF(x1 - (float)sizeX1, y1));
                        var rect = new Rect2(x1 - sizeX1, y1 - radiusY1, sizeX1, sizeY1);
                        _gfx.SaveTransform();
                        _gfx.MultiplyTransform(t1);
                        DrawRectangleInternal(_gfx, fillStartArrow, strokeStartArrow, sas.IsStroked, sas.IsFilled, ref rect);
                        _gfx.RestoreTransform();
                    }
                    break;
                case ArrowType.Ellipse:
                    {
                        pt1 = t1.TransformPoint(new PointF(x1 - (float)sizeX1, y1));
                        _gfx.SaveTransform();
                        _gfx.MultiplyTransform(t1);
                        var rect = new Rect2(x1 - sizeX1, y1 - radiusY1, sizeX1, sizeY1);
                        DrawEllipseInternal(_gfx, fillStartArrow, strokeStartArrow, sas.IsStroked, sas.IsFilled, ref rect);
                        _gfx.RestoreTransform();
                    }
                    break;
                case ArrowType.Arrow:
                    {
                        var pts = new PointF[]
                        {
                            new PointF(x1, y1),
                            new PointF(x1 - (float)sizeX1, y1 + (float)sizeY1),
                            new PointF(x1, y1),
                            new PointF(x1 - (float)sizeX1, y1 - (float)sizeY1),
                            new PointF(x1, y1)
                        };
                        pt1 = t1.TransformPoint(pts[0]);
                        var p11 = t1.TransformPoint(pts[1]);
                        var p21 = t1.TransformPoint(pts[2]);
                        var p12 = t1.TransformPoint(pts[3]);
                        var p22 = t1.TransformPoint(pts[4]);
                        DrawLineInternal(_gfx, strokeStartArrow, sas.IsStroked, ref p11, ref p21);
                        DrawLineInternal(_gfx, strokeStartArrow, sas.IsStroked, ref p12, ref p22);
                    }
                    break;
            }

            double radiusX2 = eas.RadiusX;
            double radiusY2 = eas.RadiusY;
            double sizeX2 = 2.0 * radiusX2;
            double sizeY2 = 2.0 * radiusY2;

            switch (eas.ArrowType)
            {
                default:
                case ArrowType.None:
                    {
                        pt2 = new PointF(x2, y2);
                    }
                    break;
                case ArrowType.Rectangle:
                    {
                        pt2 = t2.TransformPoint(new PointF(x2 - (float)sizeX2, y2));
                        var rect = new Rect2(x2 - sizeX2, y2 - radiusY2, sizeX2, sizeY2);
                        _gfx.SaveTransform();
                        _gfx.MultiplyTransform(t2);
                        DrawRectangleInternal(_gfx, fillEndArrow, strokeEndArrow, eas.IsStroked, eas.IsFilled, ref rect);
                        _gfx.RestoreTransform();
                    }
                    break;
                case ArrowType.Ellipse:
                    {
                        pt2 = t2.TransformPoint(new PointF(x2 - (float)sizeX2, y2));
                        _gfx.SaveTransform();
                        _gfx.MultiplyTransform(t2);
                        var rect = new Rect2(x2 - sizeX2, y2 - radiusY2, sizeX2, sizeY2);
                        DrawEllipseInternal(_gfx, fillEndArrow, strokeEndArrow, eas.IsStroked, eas.IsFilled, ref rect);
                        _gfx.RestoreTransform();
                    }
                    break;
                case ArrowType.Arrow:
                    {
                        var pts = new PointF[]
                        {
                            new PointF(x2, y2),
                            new PointF(x2 - (float)sizeX2, y2 + (float)sizeY2),
                            new PointF(x2, y2),
                            new PointF(x2 - (float)sizeX2, y2 - (float)sizeY2),
                            new PointF(x2, y2)
                        };
                        pt2 = t2.TransformPoint(pts[0]);
                        var p11 = t2.TransformPoint(pts[1]);
                        var p21 = t2.TransformPoint(pts[2]);
                        var p12 = t2.TransformPoint(pts[3]);
                        var p22 = t2.TransformPoint(pts[4]);
                        DrawLineInternal(_gfx, strokeEndArrow, eas.IsStroked, ref p11, ref p21);
                        DrawLineInternal(_gfx, strokeEndArrow, eas.IsStroked, ref p12, ref p22);
                    }
                    break;
            }

            _gfx.DrawLine(strokeLine, pt1, pt2);

            fillLine.Dispose();
            strokeLine.Dispose();

            fillStartArrow.Dispose();
            strokeStartArrow.Dispose();

            fillEndArrow.Dispose();
            strokeEndArrow.Dispose();
        }
Exemple #32
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="gfx"></param>
 /// <param name="pen"></param>
 /// <param name="isStroked"></param>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 private static void DrawLineInternal(
     Graphics gfx,
     Pen pen,
     bool isStroked,
     ref PointF p0,
     ref PointF p1)
 {
     if (isStroked)
     {
         gfx.DrawLine(pen, p0, p1);
     }
 }
Exemple #33
0
 /// <summary>
 /// Initializes a new instance of the Rectangle class with two points
 /// </summary>
 /// <remarks>
 /// This will always create a normalized rect, in that the location will be the minimum of the X and Y co-ordinates of the supplied
 /// points.
 /// </remarks>
 /// <param name="start">Starting point of the rectangle</param>
 /// <param name="end">Ending point of the rectangle</param>
 public RectangleF(PointF start, PointF end)
 {
     location = start;
     size     = new SizeF((end.X >= start.X) ? end.X - start.X + 1 : end.X - start.X, (end.Y >= start.Y) ? end.Y - start.Y + 1: end.Y - start.Y);
 }
Exemple #34
0
		void AddBezier(PointF pt2, PointF pt3, PointF pt4)
		{
			Sink.AddBezier(new sd.BezierSegment
			{
				Point1 = pt2.ToDx(),
				Point2 = pt3.ToDx(),
				Point3 = pt4.ToDx()
			});

			CurrentPoint = pt4;
		}
Exemple #35
0
 /// <summary>
 /// Restricts the rectangle to be within the specified <paramref name="location"/> and <paramref name="size"/>
 /// </summary>
 /// <remarks>
 /// This is a shortcut for <seealso cref="Restrict(Rectangle)"/>
 /// </remarks>
 /// <param name="location">Minimum location for the rectangle</param>
 /// <param name="size">Maximum size for the rectangle</param>
 public void Restrict(PointF point, SizeF size)
 {
     Restrict(new RectangleF(point, size));
 }
Exemple #36
0
 /// <summary>
 /// Initializes a new instance of the Rectangle class with the specified <paramref name="location"/> and <paramref name="size"/>
 /// </summary>
 /// <param name="location">Location of the rectangle</param>
 /// <param name="size">Size of the rectangle</param>
 public RectangleF(PointF location, SizeF size)
 {
     this.location = location;
     this.size     = size;
 }
Exemple #37
0
 /// <summary>
 /// Initializes a new instance of the Rectangle class with X, Y co-ordinates at 0,0 and the specified <paramref name="size"/>
 /// </summary>
 /// <param name="size">Size to give the rectangle</param>
 public RectangleF(SizeF size)
 {
     this.location = new PointF(0, 0);
     this.size     = size;
 }
Exemple #38
0
 /// <summary>
 /// Initializes a new instance of the Rectangle class with the specified <paramref name="x"/>, <paramref name="y"/>, <paramref name="width"/>, and <paramref name="height"/>
 /// </summary>
 /// <param name="x">X co-ordinate for the location of the rectangle</param>
 /// <param name="y">Y co-ordinate for the location of the rectangle</param>
 /// <param name="width">Width of the rectangle</param>
 /// <param name="height">Height of the rectangle</param>
 public RectangleF(float x, float y, float width, float height)
 {
     this.location = new PointF(x, y);
     this.size     = new SizeF(width, height);
 }
Exemple #39
0
 /// <summary>
 /// Gets a value indicating that the specified <paramref name="point"/> is within the bounds of this rectangle
 /// </summary>
 /// <param name="point">Point to test</param>
 /// <returns>True if the point is within the bounds of this rectangle, false if it is outside the bounds</returns>
 public bool Contains(PointF point)
 {
     return(Contains(point.X, point.Y));
 }