Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic create shapenodes along the circle (Read 1140 times)
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
create shapenodes along the circle
Jun 5th, 2017 at 5:26pm
Print Post  
using following method I can create a rectangle.

Code
Select All
diagram.Factory.CreateShapeNode(
	x coordinate, y coordinate, height, width, Shapes.Rectangle); 



but how to draw these rectangle along a circle

for ex:
If I have 3 rectangle shapenodes




If I have 4 rectangle shapenodes



If I have 6 rectangle shapenodes



like wise this should be able to follow the circle according to node count.

is it possible to populate these node around a circle like above, if yes how can I do this in dynamic node count situation also
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: create shapenodes along the circle
Reply #1 - Jun 5th, 2017 at 6:02pm
Print Post  
Just apply what you learned in your trigonometry classes Wink

Code
Select All
void CircleOfNodes(Point center, double radius, int numNodes, Size nodeSize)
{
	double angle = - Math.PI / 2;
	double delta = 2 * Math.PI / numNodes;
	for (int i = 0; i < numNodes; i++)
	{
		var pos = new Point(
			center.X + radius * Math.Cos(angle),
			center.Y + radius * Math.Sin(angle));
		var node = diagram.Factory.CreateShapeNode(
			pos.X - nodeSize.Width / 2,
			pos.Y - nodeSize.Height / 2,
			nodeSize.Width, nodeSize.Height);
		node.RotationAngle = angle * 180 / Math.PI + 90;
		//node.Text = node.RotationAngle.ToString();
		node.RotateText = true;
		angle += delta;
	}
} 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint