public static void ApplyButtonStyle(ProgramaticStyle programaticStyle, int w, int weight, TriangleDirection direction) { programaticStyle.Border = new RectOffset(weight + 1, weight + 1, weight + 1, weight + 1); var size = new Point(w, w); int pixels = w <= 20 ? 4 : 5; // the "height" of the triangle in pixels //programaticStyle.FontSize = 30; //programaticStyle.NormalTextColor = Color.grey; programaticStyle.NormalGraphics = new GraphicGroup(w, w, new Rect( new Fill(NormalColor), new Stroke(weight) { Color = StrokeColor } ), new Triangle(new Fill(ColorMixer.FromHex(0x666666).ToColor())) { Direction = direction, Pixels = pixels } ); //programaticStyle.HoverTextColor = Color.white; programaticStyle.HoverGraphics = new GraphicGroup(w, w, new Rect( new Fill(HoverColor), new Stroke(weight) { Color = StrokeColor } ), new Triangle(new Fill(Color.black)) { Direction = direction, Pixels = pixels } ); //programaticStyle.ActiveTextColor = Color.white; programaticStyle.ActiveGraphics = new GraphicGroup(w, w, new Rect( new Fill(ActiveColor), new Stroke(weight) { Color = StrokeColor } ), new Triangle(new Fill(ColorMixer.FromHex(0x333333).ToColor())) { Direction = direction, Pixels = pixels } ); }
private static Point[] BuildTrianglePoints(TriangleDirection dir, Rectangle bounds) { Point[] points = new Point[3]; int x = (int)(bounds.Width * 0.8); if ((x % 2) == 1) { x++; } int y = (int)Math.Ceiling((double)((x / 2) * 2.5)); int num3 = (int)(bounds.Height * 0.8); if ((num3 % 2) == 0) { num3++; } int num4 = (int)Math.Ceiling((double)((num3 / 2) * 2.5)); switch (dir) { case TriangleDirection.Up: points[0] = new Point(0, y); points[1] = new Point(x, y); points[2] = new Point(x / 2, 0); break; case TriangleDirection.Down: points[0] = new Point(0, 0); points[1] = new Point(x, 0); points[2] = new Point(x / 2, y); break; case TriangleDirection.Left: points[0] = new Point(num3, 0); points[1] = new Point(num3, num4); points[2] = new Point(0, num4 / 2); break; case TriangleDirection.Right: points[0] = new Point(0, 0); points[1] = new Point(0, num4); points[2] = new Point(num3, num4 / 2); break; } switch (dir) { case TriangleDirection.Up: case TriangleDirection.Down: OffsetPoints(points, bounds.X + ((bounds.Width - y) / 2), bounds.Y + ((bounds.Height - x) / 2)); return(points); case TriangleDirection.Left: case TriangleDirection.Right: OffsetPoints(points, bounds.X + ((bounds.Width - num3) / 2), bounds.Y + ((bounds.Height - num4) / 2)); return(points); } return(points); }
private static Point[] BuildTrianglePoints(TriangleDirection dir, Rectangle bounds) { Point[] array = new Point[3]; int num = (int)((double)bounds.Width * 0.8); if (num % 2 == 1) { num++; } int num2 = (int)Math.Ceiling((double)(num / 2) * 2.5); int num3 = (int)((double)bounds.Height * 0.8); if (num3 % 2 == 0) { num3++; } int num4 = (int)Math.Ceiling((double)(num3 / 2) * 2.5); switch (dir) { case TriangleDirection.Up: array[0] = new Point(0, num2); array[1] = new Point(num, num2); array[2] = new Point(num / 2, 0); break; case TriangleDirection.Down: array[0] = new Point(0, 0); array[1] = new Point(num, 0); array[2] = new Point(num / 2, num2); break; case TriangleDirection.Left: array[0] = new Point(num3, 0); array[1] = new Point(num3, num4); array[2] = new Point(0, num4 / 2); break; case TriangleDirection.Right: array[0] = new Point(0, 0); array[1] = new Point(0, num4); array[2] = new Point(num3, num4 / 2); break; } switch (dir) { case TriangleDirection.Up: case TriangleDirection.Down: OffsetPoints(array, bounds.X + (bounds.Width - num2) / 2, bounds.Y + (bounds.Height - num) / 2); break; case TriangleDirection.Left: case TriangleDirection.Right: OffsetPoints(array, bounds.X + (bounds.Width - num3) / 2, bounds.Y + (bounds.Height - num4) / 2); break; } return(array); }
public static void Paint(Graphics g, Rectangle bounds, TriangleDirection dir, Brush backBr, Pen backPen1, Pen backPen2, Pen backPen3, bool opaque) { // build an equilateral triangle centered on the midpoint of the rect. Point[] points = BuildTrianglePoints(dir, bounds); g.DrawLine(backPen1, points[0], points[1]); g.DrawLine(backPen2, points[1], points[2]); g.DrawLine(backPen3, points[2], points[0]); }
private static Point[] BuildTrianglePoints(TriangleDirection dir, Rectangle bounds) { Point[] points = new Point[3]; int x = (int) (bounds.Width * 0.8); if ((x % 2) == 1) { x++; } int y = (int) Math.Ceiling((double) ((x / 2) * 2.5)); int num3 = (int) (bounds.Height * 0.8); if ((num3 % 2) == 0) { num3++; } int num4 = (int) Math.Ceiling((double) ((num3 / 2) * 2.5)); switch (dir) { case TriangleDirection.Up: points[0] = new Point(0, y); points[1] = new Point(x, y); points[2] = new Point(x / 2, 0); break; case TriangleDirection.Down: points[0] = new Point(0, 0); points[1] = new Point(x, 0); points[2] = new Point(x / 2, y); break; case TriangleDirection.Left: points[0] = new Point(num3, 0); points[1] = new Point(num3, num4); points[2] = new Point(0, num4 / 2); break; case TriangleDirection.Right: points[0] = new Point(0, 0); points[1] = new Point(0, num4); points[2] = new Point(num3, num4 / 2); break; } switch (dir) { case TriangleDirection.Up: case TriangleDirection.Down: OffsetPoints(points, bounds.X + ((bounds.Width - y) / 2), bounds.Y + ((bounds.Height - x) / 2)); return points; case TriangleDirection.Left: case TriangleDirection.Right: OffsetPoints(points, bounds.X + ((bounds.Width - num3) / 2), bounds.Y + ((bounds.Height - num4) / 2)); return points; } return points; }
public static void Paint(Graphics g, Rectangle bounds, TriangleDirection dir, Brush backBr, Pen backPen1, Pen backPen2, Pen backPen3, bool opaque) { Point[] points = BuildTrianglePoints(dir, bounds); if (opaque) { g.FillPolygon(backBr, points); } g.DrawLine(backPen1, points[0], points[1]); g.DrawLine(backPen2, points[1], points[2]); g.DrawLine(backPen3, points[2], points[0]); }
/* Commenting this overload out until someone actually needs it again... public static void Paint(Graphics g, Rectangle bounds, TriangleDirection dir, Brush backBr, Pen backPen) { Paint(g, bounds, dir, backBr, backPen, true); } */ /* Commenting this overload out until someone actually needs it again... public static void Paint(Graphics g, Rectangle bounds, TriangleDirection dir, Brush backBr, Pen backPen, bool opaque) { // build an equilateral triangle centered on the midpoint of the rect. Point[] points = BuildTrianglePoints(dir, bounds); if (opaque) g.FillPolygon(backBr, points); g.DrawPolygon(backPen, points); } */ public static void Paint(Graphics g, Rectangle bounds, TriangleDirection dir, Brush backBr, Pen backPen1, Pen backPen2, Pen backPen3, bool opaque) { // build an equilateral triangle centered on the midpoint of the rect. Point[] points = BuildTrianglePoints(dir, bounds); if (opaque) g.FillPolygon(backBr, points); g.DrawLine(backPen1, points[0], points[1]); g.DrawLine(backPen2, points[1], points[2]); g.DrawLine(backPen3, points[2], points[0]); }
public static void Paint(Graphics g, Rectangle bounds, TriangleDirection dir, Brush backBr, Pen backPen, bool opaque) { // build an equilateral triangle centered on the midpoint of the rect. Point[] points = BuildTrianglePoints(dir, bounds); if (opaque) { g.FillPolygon(backBr, points); } g.DrawPolygon(backPen, points); }
public void reorient(TriangleDirection direction) { switch (direction) { case TriangleDirection.Upward: transform.eulerAngles = new Vector3(0, 0, -30); break; default: transform.eulerAngles = new Vector3(0, 0, 30); break; } }
/// <summary> /// Adds a triangle to the image. /// </summary> /// <param name="x">X coordinate of the bounding rectangle.</param> /// <param name="y">Y coordinate of the bounding rectangle.</param> /// <param name="width">Width of the bounding rectangle.</param> /// <param name="height">Height of the bounding rectangle.</param> /// <param name="direction">The direction of the triangle.</param> /// <param name="invert">If <c>true</c> the area of the triangle will be removed from the filled area.</param> public void AddTriangle(float x, float y, float width, float height, TriangleDirection direction, bool invert = false) { var points = new List <PointF>(4) { new PointF(x + width, y), new PointF(x + width, y + height), new PointF(x, y + height), new PointF(x, y) }; points.RemoveAt((int)direction); AddPolygonCore(points.ToArray(), invert); }
public static void FillTriangle(PlatformGraphics g, RGFloat size, Point loc, TriangleDirection dir = TriangleDirection.Down) { #if WINFORM var p = System.Drawing.Pens.Black; #elif WPF var p = new System.Windows.Media.Pen(RGBrushes.Black, 1); #elif ANDROID var p = new RGPen(); p.Color = Android.Graphics.Color.Black; #elif iOS var p = g; #endif // WPF FillTriangle(g, size, loc, dir, p); }
public static void FillTriangle(Graphics g, float size, PointF loc, TriangleDirection dir, Pen p) { float x = loc.X; float y = loc.Y; switch (dir) { case TriangleDirection.Up: loc.X -= size / 2; for (x = 0; x < size / 2; x++) { g.DrawLine(p, loc.X + x, y, loc.X + size - x - 1, y); y--; } break; case TriangleDirection.Down: loc.X -= size / 2 - 1; y--; for (x = 0; x < size / 2; x++) { g.DrawLine(p, loc.X + x, y, loc.X + size - x, y); y++; } break; case TriangleDirection.Left: loc.Y -= size / 2; for (y = 0; y < size / 2; y++) { g.DrawLine(p, x, loc.Y + y, x, loc.Y + size - y - 1); x--; } break; case TriangleDirection.Right: loc.Y -= size / 2; for (y = 0; y < size / 2; y++) { g.DrawLine(p, x, loc.Y + y, x, loc.Y + size - y - 1); x++; } break; } }
public static void FillTriangle(PlatformGraphics g, RGFloat size, Point loc, TriangleDirection dir, RGPen p) { RGFloat x = loc.X; RGFloat y = loc.Y; switch (dir) { case TriangleDirection.Up: loc.X -= size / 2; for (x = 0; x < size / 2; x++) { g.DrawLine(p, new Point(loc.X + x, y), new Point(loc.X + size - x - 1, y)); y--; } break; case TriangleDirection.Down: loc.X -= size / 2 - 1; y--; for (x = 0; x < size / 2; x++) { g.DrawLine(p, new Point(loc.X + x, y), new Point(loc.X + size - x, y)); y++; } break; case TriangleDirection.Left: loc.Y -= size / 2; for (y = 0; y < size / 2; y++) { g.DrawLine(p, new Point(x, loc.Y + y), new Point(x, loc.Y + size - y - 1)); x--; } break; case TriangleDirection.Right: loc.Y -= size / 2; for (y = 0; y < size / 2; y++) { g.DrawLine(p, new Point(x, loc.Y + y), new Point(x, loc.Y + size - y - 1)); x++; } break; } }
public static void FillTriangle(Graphics g, int size, Point loc, TriangleDirection dir) { int x = loc.X; int y = loc.Y; switch (dir) { case TriangleDirection.Up: loc.X -= size / 2; for (x = 0; x < size / 2; x++) { g.DrawLine(Pens.Black, loc.X + x, y, loc.X + size - x - 1, y); y--; } break; case TriangleDirection.Down: loc.X -= size / 2; for (x = 0; x < size / 2; x++) { g.DrawLine(Pens.Black, loc.X + x, y, loc.X + size - x - 1, y); y++; } break; case TriangleDirection.Left: loc.Y -= size / 2; for (y = 0; y < size / 2; y++) { g.DrawLine(Pens.Black, x, loc.Y + y, x, loc.Y + size - y - 1); x--; } break; case TriangleDirection.Right: loc.Y -= size / 2; for (y = 0; y < size / 2; y++) { g.DrawLine(Pens.Black, x, loc.Y + y, x, loc.Y + size - y - 1); x++; } break; } }
public static void FillTriangle(Graphics g, int size, Point loc, TriangleDirection dir, Pen p) { int x = loc.X; int y = loc.Y; switch (dir) { case TriangleDirection.Up: loc.X -= size / 2; for (x = 0; x < size / 2 ; x++) { g.DrawLine(p, loc.X + x, y, loc.X + size - x - 1, y); y--; } break; case TriangleDirection.Down: loc.X -= size / 2; for (x = 0; x < size / 2 ; x++) { g.DrawLine(p, loc.X + x, y, loc.X + size - x - 1, y); y++; } break; case TriangleDirection.Left: loc.Y -= size / 2; for (y = 0; y < size / 2 ; y++) { g.DrawLine(p, x, loc.Y + y, x, loc.Y + size - y - 1); x--; } break; case TriangleDirection.Right: loc.Y -= size / 2; for (y = 0; y < size / 2 ; y++) { g.DrawLine(p, x, loc.Y + y, x, loc.Y + size - y - 1); x++; } break; } }
private static Point[] BuildTrianglePoints(TriangleDirection dir, Rectangle bounds) { Point[] points = new Point[3]; int updnWidth = (int)(bounds.Width * TRI_WIDTH_RATIO); if (updnWidth % 2 == 1) { updnWidth++; } int updnHeight = (int)Math.Ceiling((updnWidth / 2) * TRI_HEIGHT_RATIO); int lrWidth = (int)(bounds.Height * TRI_WIDTH_RATIO); if (lrWidth % 2 == 0) { lrWidth++; } int lrHeight = (int)Math.Ceiling((lrWidth / 2) * TRI_HEIGHT_RATIO); switch (dir) { case TriangleDirection.Up: { points[0] = new Point(0, updnHeight); points[1] = new Point(updnWidth, updnHeight); points[2] = new Point(updnWidth / 2, 0); } break; case TriangleDirection.Down: { points[0] = new Point(0, 0); points[1] = new Point(updnWidth, 0); points[2] = new Point(updnWidth / 2, updnHeight); } break; case TriangleDirection.Left: { points[0] = new Point(lrWidth, 0); points[1] = new Point(lrWidth, lrHeight); points[2] = new Point(0, lrHeight / 2); } break; case TriangleDirection.Right: { points[0] = new Point(0, 0); points[1] = new Point(0, lrHeight); points[2] = new Point(lrWidth, lrHeight / 2); } break; default: Debug.Fail("Wrong triangle enum"); break; } // we need to center our triangles into the bounds given. // NOTE: On the up/down case, the offsets are different! switch (dir) { case TriangleDirection.Up: case TriangleDirection.Down: OffsetPoints(points, bounds.X + (bounds.Width - updnHeight) / 2, bounds.Y + (bounds.Height - updnWidth) / 2); break; case TriangleDirection.Left: case TriangleDirection.Right: OffsetPoints(points, bounds.X + (bounds.Width - lrWidth) / 2, bounds.Y + (bounds.Height - lrHeight) / 2); break; } return(points); }
public static void Paint(Graphics g, Rectangle bounds, TriangleDirection dir, Brush backBr, Pen backPen) { Paint(g, bounds, dir, backBr, backPen, true); }
public static void FillTriangle(Graphics g, float size, PointF loc, TriangleDirection dir) { FillTriangle(g, size, loc, dir, Pens.Black); }
private static Point[] BuildTrianglePoints(TriangleDirection dir, Rectangle bounds) { Point[] points = new Point[3]; int updnWidth =(int)(bounds.Width * TRI_WIDTH_RATIO); if (updnWidth % 2 == 1) updnWidth++; int updnHeight =(int)Math.Ceiling((updnWidth/2) * TRI_HEIGHT_RATIO); int lrWidth =(int)(bounds.Height * TRI_WIDTH_RATIO); if (lrWidth % 2 == 0) lrWidth++; int lrHeight =(int)Math.Ceiling((lrWidth/2) * TRI_HEIGHT_RATIO); switch (dir) { case TriangleDirection.Up: { points[0] = new Point(0, updnHeight); points[1] = new Point(updnWidth, updnHeight); points[2] = new Point(updnWidth / 2, 0); } break; case TriangleDirection.Down: { points[0] = new Point(0, 0); points[1] = new Point(updnWidth, 0); points[2] = new Point(updnWidth / 2, updnHeight); } break; case TriangleDirection.Left: { points[0] = new Point(lrWidth, 0); points[1] = new Point(lrWidth, lrHeight); points[2] = new Point(0, lrHeight / 2); } break; case TriangleDirection.Right: { points[0] = new Point(0, 0); points[1] = new Point(0, lrHeight); points[2] = new Point(lrWidth, lrHeight / 2); } break; default: Debug.Fail("Wrong triangle enum"); break; } // we need to center our triangles into the bounds given. // NOTE: On the up/down case, the offsets are different! switch (dir) { case TriangleDirection.Up: case TriangleDirection.Down: OffsetPoints(points, bounds.X +(bounds.Width - updnHeight)/2, bounds.Y +(bounds.Height - updnWidth)/2); break; case TriangleDirection.Left: case TriangleDirection.Right: OffsetPoints(points, bounds.X +(bounds.Width - lrWidth)/2, bounds.Y +(bounds.Height - lrHeight)/2); break; } return points; }
public static void FillTriangle(PlatformGraphics g, RGFloat size, Point loc, TriangleDirection dir = TriangleDirection.Down) { var p = System.Drawing.Pens.Black; FillTriangle(g, size, loc, dir, p); }
public static void FillTriangle(Graphics g, int size, Point loc, TriangleDirection dir) { FillTriangle(g, size, loc, dir, Pens.Black); }