473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Draw fractal Fit inside panel using Winform?

Hi I am trying to build a windows application in .net which draw fractal image inside the panel.It take end points of line as starting point of next line.But problem is, diagram is going outside of the panel.How do i fix drawing inside the panel
Expand|Select|Wrap|Line Numbers
  1.  static int start_x, start_Y;
  2.         static int end_x, end_Y;
  3.         static int my_angle = 0;
  4.         static int my_length = 0;
  5.  
  6.  public void draw_line()
  7.         {
  8.  
  9.              Pen mypen = new Pen(Color.Orange, 2F);
  10.                 my_angle = my_angle + (74);
  11.                 my_length = 100 + (1);
  12.  
  13.                 end_x = (int)(start_x + Math.Cos(my_angle * .0174539676) * my_length);
  14.  
  15.                 end_Y = (int)(start_Y + Math.Sin(my_angle * .0174539676) * my_length);
  16.                 Point[] points =
  17.             {
  18.                 new Point (start_x,start_Y),
  19.                 new Point (end_x,end_Y)
  20.             };
  21.                 start_x = end_x;
  22.                 start_Y = end_Y;
  23.  
  24.  
  25.             Graphics g = panel1.CreateGraphics();
  26.              g.DrawLines(mypen, points);
  27.  
  28.         }
  29.  private void panel1_Paint(object sender, PaintEventArgs e)
  30.         {
  31.             start_x = panel1.Width / 2;
  32.             start_Y = panel1.Height / 2;
  33.             for (int i = 0; i < 400; i++)
  34.                 draw_line();
  35.         }
  36.  
  37.  
Sep 12 '14 #1
0 1155

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ram | last post by:
hi! can you suggest me a collapsible panel/groupbox for winform. thanks!
8
by: Sunil Menon | last post by:
Dear All, We are developing applications in ASP.Net...in one of our applications we would like to use a GridControl...we have tried to use a Server-Side Grid control but found the speed to be an...
8
by: Andrew Robinson | last post by:
Are these two equivalent? Is one better than the other? I tend to go with #1 but started wondering.... Thanks, 1: using (SqlConnection cn = new SqlConnection(DataConnection)) using...
0
by: vijaykumarairbee | last post by:
hi, i have panel control with network images pan,routers etc. when i scroll my panel control the images refresh rate is very slow.it means while i scroll the panel images go inside the panel after...
2
by: gurusshetty | last post by:
Hi Please help me in finding out no. of rows in data table inside dataset using c# thanks guru
1
by: sunildani | last post by:
write a program to Draw an ellipse's using polynimial equation ((x-h)^2/a^2 + ((y-k)^2)/b^2 =1
0
by: =?Utf-8?B?Y2hpdHRvcmlhbg==?= | last post by:
I am trying to draw lines between buttons inside two different wrap panel ..This has to happen on click of button .The partial code goes below. UserControlButton btn = (UserControlButton)sender;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.