public void RunOnce(IDraw2D aPort) { int cxClient = fSize.Width; int cyClient = fSize.Height; //aPort.SaveState(); GDIPen rectPen = new GDICosmeticPen(PenStyle.Solid, RGBColor.Black, Guid.NewGuid()); GDISolidBrush rectBrush = new GDISolidBrush(RGBColor.White); // Do a rectangle Rectangle rect = Rectangle.FromLTRB(cxClient / 8, cyClient / 8, (7 * cxClient / 8), (7 * cyClient / 8)); aPort.FillRectangle(rectBrush, rect); aPort.DrawRectangle(rectPen, rect); // Now do a couple of lines using a dash/dot/dot pen GDIPen aPen = new GDIPen(PenType.Cosmetic, PenStyle.DashDotDot, PenJoinStyle.Round, PenEndCap.Round, RGBColor.Black, 1, Guid.NewGuid()); aPort.DrawLine(aPen, new Point(0, 0), new Point(cxClient, cyClient)); aPort.DrawLine(aPen, new Point(0, cyClient), new Point(cxClient, 0)); // Now an ellipse aPort.DrawEllipse(aPen, rect); // Last, a rounded rectangle Rectangle rRect = Rectangle.FromLTRB(cxClient / 4, cyClient / 4, 3 * cxClient / 4, 3 * cyClient / 4); aPort.DrawRoundRect(aPen, rRect, cxClient / 4, cyClient / 4); //aPort.ResetState(); }
private void Awake() { #if USE_SHAPER_2D_LIBRARY draw2D = new Draw2DShaperImpl(); #else draw2D = new Draw2DDummyImpl(); Debug.LogWarning("The USE_SHAPER_2D_LIBRARY preprocessor flag is not set. You will have NO game-generated 2D graphics! If you want game-generated 2D graphics, see README. If this is intentional, you can also just remove this error message :)"); #endif bitmapFont = draw2D.CreateBitmapFont(bitmapFontXml, bitmapFontImage); Util.FindIfNotSet(this, ref engine); Util.FindIfNotSet(this, ref imageSystem); Util.FindIfNotSet(this, ref imageLoader); }
public void RunOnce(IDraw2D aPort) { //aPort.SaveState(); GPen rectPen = new GPen(RGBColor.Red); GDIBrush rectBrush = new GDISolidBrush(RGBColor.Pink); for (int coord = 10; coord < fSize.Height; coord += 50) { aPort.FillRectangle(rectBrush, new Rectangle(coord, coord, 200, 200)); aPort.DrawRectangle(rectPen, new Rectangle(coord, coord, 200, 200)); } //aPort.ResetState(); }
public void RunOnce(IDraw2D aPort) { int i; int cxClient = fSize.Width; int cyClient = fSize.Height; Point[] points = new Point[fNumSegments]; //aPort.SaveState(); aPort.DrawLine(redPen, new Point(0, cyClient/2), new Point(cxClient, cyClient / 2)); for (i = 0; i < fNumSegments; i++) { points[i].X = i * cxClient / fNumSegments; points[i].Y = (int)(((double)cyClient/2.0f)*(1.0f-Math.Sin(Math.PI*2.0f*(double)i/(double)fNumSegments))); } aPort.DrawLines(linePen, points); //aPort.ResetState(); }
/// <summary> /// Remove an object of type IDraw2D to the engine. /// </summary> /// <param name="e"></param> public void UntrackDraw2D(IDraw2D e) { Draw2DList.Remove(e); }
/// <summary> /// Add an object of type IDraw2D to the engine. /// </summary> /// <param name="e"></param> public void TrackDraw2D(IDraw2D e) { Draw2DList.Add(e); }