找传奇、传世资源到传世资源站!

利用定时器、双缓存在窗体上实现动画

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

利用定时器、双缓存在窗体上画图,并实现动画
利用定时器、双缓存在窗体上实现动画 C#图形和图像处理-第1张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;namespace MyForm{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) {//启动有窗体定时器 if (this.timer11.Enabled == false) { this.timer11.Start(); } x = 10; y = 50; } private void button2_Click(object sender, EventArgs e) {//关闭有窗体定时器 this.timer11.Stop(); } private void timer1_Tick(object sender, EventArgs e) { x = x 2; w = 40; h = 40; Bitmap bmp = new Bitmap(this.Width, this.Height-50); Graphics buffergraphics = Graphics.FromImage(bmp); Color bc = this.BackColor; buffergraphics.FillRectangle(new SolidBrush(bc), 0, 0, this.Width - 1, this.Height - 1); buffergraphics.DrawEllipse(Pens.Blue, x, y, w, h); //4、将内存画布画到窗口中 Graphics g; g = this.CreateGraphics(); g.DrawImage(bmp, 0, 50); } public int x, y, w, h; private void Form1_Load(object sender, EventArgs e) {//初始化图形数据 this.timer11.Interval = 20; x = 10; y = 50; } private void panel1_Paint(object sender, PaintEventArgs e) { } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复