internal override void InitializeVertices(CellOperationInitialize <Point2D, Box2D> cellInit) { FillVertices(vertices, BoundsBox); Center = Geometric.CenterPoint(vertices[0], vertices[VertexCount / 2]); if (cellInit.UseEffect3D) { FillVertices(verticesEffect3D, Box2D.Inflate(BoundsBox, -Geometric.CellOffset, -Geometric.CellOffset)); } }
private void DrawText(Point2D centerPosition, Box2D box, string text, SolidBrush textBrush) { if (!Geometric.CheckBox(box)) { return; } Font font = new Font(FontName, box.Height, FontStyle.Bold); Graph.DrawString(text, font, textBrush, centerPosition, GetTextAlign()); }
/// <summary> /// Initializes double buffer /// </summary> #endregion public void BeginPaint(Box2D box) { if (Geometric.CheckBox(box)) { box = Box2D.Inflate(box, Geometric.FieldOffset, Geometric.FieldOffset); bitmapBuffer = new Bitmap((int)(box.Width), (int)(box.Height), graph); graphBuffer = Graphics.FromImage(bitmapBuffer); //gdiSelector.BitmapSize = boxBounds.Size;// if selector in painter } Graph.Clear(BackColor); }
/// <summary> /// Set points of the elliptic curve use clockwise direction of /// starting angle from the x-axis. /// </summary> /// <returns> /// Returns center point of current elliptic segment. /// </returns> #endregion public static Point2D CalculateEllipticPoints(Point2D[] points, int pointsCount, int startIndex, Box2D bounds, double startAngle, double sweepAngle, bool isReverseOrder) { double angle, majorRadius, minorRadius, sinus, cosinus; double sweep = Geometric.Radian(sweepAngle / (pointsCount - 1)); if (bounds.Width > bounds.Height) { majorRadius = bounds.Width / 2; minorRadius = bounds.Height / 2; sinus = 0; cosinus = 1; angle = Geometric.Radian(startAngle); } else { majorRadius = bounds.Height / 2; minorRadius = bounds.Width / 2; sinus = 1; cosinus = 0; angle = Geometric.Radian(startAngle - 90); } int beginIndex = startIndex; int sign = 1; if (isReverseOrder) { sign = -sign; beginIndex += pointsCount - 1; } int index; double x, y; double cX = (bounds.Left + bounds.Right) / 2; double cY = (bounds.Top + bounds.Bottom) / 2; for (int i = 0; i < pointsCount; i++) { index = beginIndex + sign * i; x = majorRadius * Math.Cos(angle); y = minorRadius * Math.Sin(angle); points[index].X = (Float2D)(cX + x * cosinus - y * sinus); points[index].Y = (Float2D)(cY + x * sinus + y * cosinus); angle += sweep; } index = startIndex + pointsCount / 2; if (pointsCount % 2 == 0) { return(Geometric.CenterPoint(points[index - 1], points[index])); } else { return(points[index]); } }
internal override void InitializeVertices(CellOperationInitialize <Point2D, Box2D> cellInit) { Point2D centerElliptic = Geometric.CalculateEllipticPoints(vertices, VertexCount, 0, cellInit.ExtentsBox, 0, 360, true); Center = Geometric.CenterPoint(vertices[0], centerElliptic); if (cellInit.UseEffect3D) { cellInit.ExtentsBox = Box2D.Inflate(cellInit.ExtentsBox, -Geometric.CellOffset, -Geometric.CellOffset); Geometric.CalculateEllipticPoints(verticesEffect3D, VertexCount, 0, cellInit.ExtentsBox, 0, 360, true); } }
internal override void InitializeVertices(CellOperationInitialize <Point2D, Box2D> cellInit) { int count = VertexCount / 2; Point2D center1 = Geometric.CalculateEllipticPoints(vertices, count, 0, cellInit.BigBox, cellInit.StartAngle, cellInit.SweepAngle, true); Point2D center2 = Geometric.CalculateEllipticPoints(vertices, count, count, cellInit.SmallBox, cellInit.StartAngle, cellInit.SweepAngle, false); Center = Geometric.CenterPoint(center1, center2); if (cellInit.UseEffect3D) { Box2D bigBox = Box2D.Inflate(cellInit.BigBox, -Geometric.CellOffset, -Geometric.CellOffset); Box2D smallBox = Box2D.Inflate(cellInit.SmallBox, Geometric.CellOffset, Geometric.CellOffset); double bigOffset = Geometric.Degree(Geometric.EllipticAngle(Geometric.CellOffset, bigBox.Size)); double smallOffset = Geometric.Degree(Geometric.EllipticAngle(Geometric.CellOffset, smallBox.Size)); Geometric.CalculateEllipticPoints(verticesEffect3D, count, 0, bigBox, cellInit.StartAngle + bigOffset, cellInit.SweepAngle - 2 * bigOffset, true); Geometric.CalculateEllipticPoints(verticesEffect3D, count, count, smallBox, cellInit.StartAngle + smallOffset, cellInit.SweepAngle - 2 * smallOffset, false); } }