コード例 #1
0
ファイル: Xlib.cs プロジェクト: jjenki11/blaze-chem-rendering
	extern public static int XFillPolygon
			(IntPtr display, XDrawable drawable, IntPtr gc,
			 XPoint[] points, int npoints,
			 int shape, int mode);
コード例 #2
0
ファイル: Xlib.cs プロジェクト: jjenki11/blaze-chem-rendering
	extern public static int XDrawPoints
			(IntPtr display, XDrawable drawable, IntPtr gc,
			 XPoint[] points, int npoints, int mode);
コード例 #3
0
ファイル: Xlib.cs プロジェクト: jjenki11/blaze-chem-rendering
	extern public static IntPtr XPolygonRegion
			(XPoint[] points, int n, int fill_rule);
コード例 #4
0
	/// <summary>
	/// <para>Construct a new <see cref="T:Xsharp.Region"/>
	/// instance that is initially set to a polygon.</para>
	/// </summary>
	///
	/// <param name="points">
	/// <para>An array of points that defines the polygon.</para>
	/// </param>
	///
	/// <param name="fillRule">
	/// <para>The area fill rule to use for the polygon.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>Raised if <paramref name="points"/> is <see langword="null"/>.
	/// </para>
	/// </exception>
	///
	/// <exception cref="T:System.ArgumentOutOfRangeException">
	/// <para>Raised if <paramref name="points"/> has less than 3
	/// elements.</para>
	/// </exception>
	///
	/// <exception cref="T:Xsharp.XException">
	/// <para>Raised if any of the elements in <paramref name="points"/>
	/// has co-ordinates that are out of range, or if
	/// <paramref name="fillRule"/> is invalid.</para>
	/// </exception>
	public Region(Point[] points, FillRule fillRule)
			{
				// Validate the parameters.
				if(points == null)
				{
					throw new ArgumentNullException("points");
				}
				else if(points.Length < 3)
				{
					throw new ArgumentOutOfRangeException
						("points", S._("X_PolygonNeeds3Pts"));
				}

				// Convert "points" into an "XPoint[]" array.
				XPoint[] pts = new XPoint [points.Length];
				try
				{
					checked
					{
						for(int index = 0; index < points.Length; ++index)
						{
							pts[index].x = (short)(points[index].x);
							pts[index].y = (short)(points[index].y);
						}
					}
				}
				catch(OverflowException)
				{
					throw new XException(S._("X_PointCoordRange"));
				}

				// Validate the fill rule.
				if(fillRule != FillRule.EvenOddRule &&
				   fillRule != FillRule.WindingRule)
				{
					throw new XException
						(String.Format(S._("X_FillRule"), (int)fillRule));
				}

				// Create the polygon region.
				lock(typeof(Region))
				{
					region = Xlib.XPolygonRegion(pts, pts.Length,
												 (int)fillRule);
					if(region == IntPtr.Zero)
					{
						Display.OutOfMemory();
					}
				}
			}
コード例 #5
0
	/// <summary>
	/// <para>Draw an arc, with lines joining to the center.</para>
	/// </summary>
	///
	/// <param name="x">
	/// <para>The X co-ordinate of the top-left point of
	/// the arc's bounding rectangle.</para>
	/// </param>
	///
	/// <param name="y">
	/// <para>The Y co-ordinate of the top-left point of
	/// the arc's bounding rectangle.</para>
	/// </param>
	///
	/// <param name="width">
	/// <para>The width of the arc's bounding rectangle.  The pixel at
	/// <i>x + width - 1</i> is the right-most side of the rectangle.</para>
	/// </param>
	///
	/// <param name="height">
	/// <para>The height of the arc's bounding rectangle.  The pixel at
	/// <i>y + height - 1</i> is the bottom-most side of the rectangle.</para>
	/// </param>
	///
	/// <param name="startAngle">
	/// <para>The starting angle for the arc, in degrees.</para>
	/// </param>
	///
	/// <param name="sweepAngle">
	/// <para>The sweep angle for the arc, in degrees.</para>
	/// </param>
	///
	/// <exception cref="T:Xsharp.XException">
	/// <para>One of the co-ordinate or size values is out of range.</para>
	/// </exception>
	public void DrawPie(int x, int y, int width, int height,
						float startAngle, float sweepAngle)
			{
				if(x < -32768 || x > 32767 || width < -32768 || width > 32767 ||
				   y < -32768 || y > 32767 || height < -32768 || height > 32767)
				{
					throw new XException(S._("X_RectCoordRange"));
				}
				if(width > 0 && height > 0)
				{
					try
					{
						// Draw the arc portion.
						IntPtr display = Lock();
						Xlib.XDrawArc(display, drawableHandle, gc,
									  x, y, width, height,
									  (int)(startAngle * 64.0f),
									  (int)(sweepAngle * 64.0f));

					#if CONFIG_EXTENDED_NUMERICS
						// Calculate the location of the arc end-points
						// and then draw the connecting arc pie lines.
						XPoint[] xpoints = new XPoint [3];
						int xaxis = width / 2;
						int yaxis = height / 2;
						int xmiddle = x + xaxis;
						int ymiddle = y + yaxis;
						double radians = startAngle * Math.PI / 180.0;
						xpoints[0].x =
							(short)(xmiddle + Math.Cos(radians) * xaxis);
						xpoints[0].y =
							(short)(ymiddle - Math.Sin(radians) * yaxis);
						xpoints[1].x = (short)xmiddle;
						xpoints[1].y = (short)ymiddle;
						radians = (startAngle + sweepAngle) * Math.PI / 180.0;
						xpoints[2].x =
							(short)(xmiddle + Math.Cos(radians) * xaxis);
						xpoints[2].y =
							(short)(ymiddle - Math.Sin(radians) * yaxis);
						Xlib.XDrawLines(display, drawableHandle, gc, xpoints,
										3, 0 /* CoordModeOrigin */);
					#endif
					}
					finally
					{
						dpy.Unlock();
					}
				}
			}
コード例 #6
0
	/// <summary>
	/// <para>Draw a list of points.</para>
	/// </summary>
	///
	/// <param name="points">
	/// <para>An array of points to be drawn.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>Raised if <paramref name="points"/> is <see langword="null"/>.
	/// </para>
	/// </exception>
	///
	/// <exception cref="T:Xsharp.XException">
	/// <para>One of the co-ordinate values is out of range, or
	/// <paramref name="points"/> has less than 1 element.</para>
	/// </exception>
	public void DrawPoints(Point[] points)
			{
				int len;

				// Validate the parameter.
				if(points == null)
				{
					throw new ArgumentNullException("points");
				}
				len = points.Length;
				if(len < 1)
				{
					throw new XException(S._("X_Need1Point"));
				}
				else if(len > (dpy.MaxRequestSize() - 3))
				{
					throw new XException(S._("X_MaxReqSizeExceeded"));
				}

				// Convert the "Point" array into an "XPoint" array.
				XPoint[] xpoints = new XPoint [len];
				int pt;
				for(pt = 0; pt < len; ++pt)
				{
					xpoints[pt] = new XPoint(points[pt].x, points[pt].y);
				}

				// Draw the points.
				try
				{
					IntPtr display = Lock();
					Xlib.XDrawPoints(display, drawableHandle, gc, xpoints,
									 len, 0 /* CoordModeOrigin */);
				}
				finally
				{
					dpy.Unlock();
				}
			}