| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1533 人关注过本帖
标题:求高手指点,画几个同心圆,运行不出来,怎么回事呢?
取消只看楼主 加入收藏
xintuhai
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2014-10-12
结帖率:33.33%
收藏
已结贴  问题点数:2 回复次数:0 
求高手指点,画几个同心圆,运行不出来,怎么回事呢?
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace demo10
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle rect = new Rectangle();
            //圆的直径等于绘图区域的最短边
            float diameter = Math.Min(rect.Width, rect.Height);
            //半径
            float radius = diameter / 2;
            //圆心
            PointF center = new PointF(rect.X + rect.Width / 2, rect.Height / 2);
            //画几个圆,先试试5个
            int count = 5;
            float diameterStep = diameter / count;
            float radiusStep = radius / count;
            //生成圆的范围
            RectangleF cirleRect = new RectangleF();
            cirleRect.X = center.X - radius;
            cirleRect.Y = center.Y - radius;
            cirleRect.Width = cirleRect.Height = diameter;
            //画同心圆
            for (int i = 0; i < count; i++)
            {
                g.DrawEllipse(Pens.Gray, cirleRect);
                cirleRect.X += radiusStep;
                cirleRect.Y += radiusStep;
                cirleRect.Width -= diameterStep;
                cirleRect.Height -= diameterStep;
            }

        }

    }
}
搜索更多相关主题的帖子: private public 同心圆 
2015-01-24 21:14
快速回复:求高手指点,画几个同心圆,运行不出来,怎么回事呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027274 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved