c# 用gdi+图形移动
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point centerPoint = new Point(160, 80);
int R = 60;
GraphicsPath path = new GraphicsPath();
path.AddEllipse(centerPoint.X - R, centerPoint.Y - R, 2 * R, 2 * R);
PathGradientBrush brush = new PathGradientBrush(path);
brush.CenterPoint = centerPoint;
brush.CenterColor = Color.White;
brush.SurroundColors = new Color[] { Color.Red };
g.FillEllipse(brush, centerPoint.X - R, centerPoint.Y - R, 2 * R, 2 * R);
}
}
}
是这个图形能移动 ,万分感谢 展开
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point centerPoint = new Point(160, 80);
int R = 60;
GraphicsPath path = new GraphicsPath();
path.AddEllipse(centerPoint.X - R, centerPoint.Y - R, 2 * R, 2 * R);
PathGradientBrush brush = new PathGradientBrush(path);
brush.CenterPoint = centerPoint;
brush.CenterColor = Color.White;
brush.SurroundColors = new Color[] { Color.Red };
g.FillEllipse(brush, centerPoint.X - R, centerPoint.Y - R, 2 * R, 2 * R);
}
}
}
是这个图形能移动 ,万分感谢 展开
1个回答
展开全部
不用移动,在新的位置重新画一个就行了。
public partial class Form1 : Form
{
Point centerPoint = new Point(160, 80);//找个地方修改centerPoint的值,画出来的图形就会移动了。
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
int R = 60;
GraphicsPath path = new GraphicsPath();
path.AddEllipse(centerPoint.X - R, centerPoint.Y - R, 2 * R, 2 * R);
PathGradientBrush brush = new PathGradientBrush(path);
brush.CenterPoint = centerPoint;
brush.CenterColor = Color.White;
brush.SurroundColors = new Color[] { Color.Red };
g.FillEllipse(brush, centerPoint.X - R, centerPoint.Y - R, 2 * R, 2 * R);
centerPoint = new Point(centerPoint.X+5 , 80);//最好不要在Paint事件里修改它。。。
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询