问题描述:使用C1FlashCanvas绘制Flash单帧画面或背景
问题解答:本文介绍C1FlashCanvas控件绘制Flash单帧画面或背景的方法。C1FlashCanvas是一个与.NET图形类相似的组件,包含了与.NET Graphics类完全相同的绘制图形的方法和属性。
关键代码:
- private Pen _pen = new Pen(Color.Black);
- _pen.Color = this.panel_DrawColor.BackColor;
- _pen.Width = (int)this.upd_LineWidth.Value;
- for(int i = 0; i < 20; i++)
- this.c1FlashCanvas1.DrawRectangle(_pen, RandomRectangle());
-
- private Rectangle RandomRectangle()
- {
- int maxWidth = this.c1FlashCanvas1.Width;
- int maxHeight = this.c1FlashCanvas1.Height;
- Point pos = new Point(_rand.Next(_minSize, maxWidth), _rand.Next(_minSize, maxHeight));
- int width = _rand.Next(_minSize, maxWidth/2);
- int height = _rand.Next(_minSize, maxHeight/2);
-
- return new Rectangle(pos, new Size(width, height));
- }
复制代码
效果截图:
源码下载:
使用C1FlashCanvas绘制Flash单帧画面或背景示例 |