Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. var count = 100;
  2. double PIES = Math.PI / count;
  3. Point center = new Point(CanvasPanel.ActualWidth / 2, CanvasPanel.ActualHeight / 2);
  4. double radius = 500;//0.1333 * Math.Min(CanvasPanel.ActualWidth, CanvasPanel.ActualHeight);
  5. for (int i = 0; i <= count; i++)
  6. {
  7. Path path1 = new Path();
  8. PathGeometry pathGeo = new PathGeometry();
  9. PathFigure PathFig = new PathFigure();
  10.  
  11. double radians = 2 * Math.PI * i / count;
  12.  
  13. PathFig.StartPoint = center;
  14. PathFig.Segments.Add(new LineSegment(new Point(center.X + radius * Math.Cos(radians + PIES), center.Y - radius * Math.Sin(radians + PIES)), true));
  15. PathFig.Segments.Add(new ArcSegment(new Point(center.X + radius * Math.Cos(radians + 3 * PIES), center.Y - radius * Math.Sin(radians + 3 * PIES)), new Size(500, 500), 1, false, SweepDirection.Counterclockwise, true));
  16. PathFig.Segments.Add(new LineSegment(center, true));
  17. PathFig.IsClosed = true;
  18. PathFig.IsFilled = true;
  19. pathGeo.Figures.Add(PathFig);
  20. pathGeo.FillRule = FillRule.Nonzero;
  21. path1.Data = pathGeo;
  22. path1.Stroke = Brushes.Black;
  23. path1.Fill = Brushes.White;
  24.  
  25. path1.StrokeThickness = 0.25;
  26.  
  27. CanvasPanel.Children.Add(path1);
  28. }
  29. for (int i = count; i >= 0; i--)
  30. {
  31. double radians = 2 * Math.PI * i / count;
  32.  
  33. var text = new TextBlock()
  34. {
  35. Height = 30,
  36. Background = Brushes.Transparent,
  37. Text = "Lorem",
  38. FontFamily = new FontFamily("Verdana"),
  39. FontSize = 15,
  40. RenderTransform = new TranslateTransform
  41. {
  42. X = center.X + 400 * Math.Cos(radians + PIES) - 50,
  43. Y = center.Y - 400 * Math.Sin(radians + PIES) - 50
  44. },
  45. LayoutTransform = i < count / 2 ? new RotateTransform(radians/ (Math.PI / 180)) : new RotateTransform(-1 * radians/ (Math.PI / 180))
  46. };
  47.  
  48. CanvasPanel.Children.Add(text);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement