C#Region Clip? [英] C# Region Clip?

查看:204
本文介绍了C#Region Clip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有一个矩形和3-4个圆圈,它们更大但不覆盖整个矩形。如何显示圆圈的区域被剪切为矩形? (仅在矩形内可见?)

Currently, i have a rectangle and 3-4 circles which are bigger but not covering the entire rectangle. How can i show that the region for the circles are clipped to the rectangle? (Only visible within the rectangle?)

推荐答案

在矩形内绘制它们?你现在如何绘制它们?
Draw them inside the rectangle ? How are you drawing them now ?


显而易见的是将一个面板放在屏幕上,这是一个矩形,根据需要对它进行着色,并让你的圈子成为那个控件的子项,由控制的油漆事件绘制。然后他们将留在矩形内。
The obvious thing would be to put a panel on the screen, which is a rectangle, color it as desired, and make your circles children of that control, painted by that control's paint event. Then they will stay inside the rectangle.


我从网上获得的一些示例代码。

Some example codes i got from the web.
Graphics g = e.Graphics;
           Pen pen = new Pen(Color.Red, 5);
           SolidBrush brush = new SolidBrush(Color.Red);
           Rectangle rect1 = new Rectangle(50, 0, 50, 150);
           Rectangle rect2 = new Rectangle(0, 50, 150, 50);
           Region region = new Region(rect1);
           region.Intersect(rect2);
           g.FillRegion(brush, region);





现在,我有两个ArrayLists - 一个包含rectanlges obj,另一个包含circle obj。圆圈随机放置,有些覆盖矩形。



我想剪切这些圆圈的区域,以便圆圈在每个矩形中可见?因为如果检测矩形本身的圆圈,我会做.isVisible方法。我迷失在这里..请帮助..



Right now, i have two ArrayLists - one contains the rectanlges obj and one contains the circles obj . The circles are palced randomly, some overlay the rectangles.

I would like to clip the regions of those circles such that circles will be visible within each rect? As i'll will be doing the .isVisible method if detecting the circles in the rectange itself. I'm lost lopping here.. pls help..


这篇关于C#Region Clip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆