我需要在 win 窗体 C# 中创建维恩图。我一直在尝试使用 Graphics.DrawEllipse 和 FillElipse 来做到这一点。但是我不确定如何填写公共(public)部分。
我想实现这个,
这是我的代码,
private void panelControlVennDiagram_Paint(object sender, PaintEventArgs e)
{
Brush brushLeft = new SolidBrush(Color.Blue);
Brush brushRight = new SolidBrush(Color.LightPink);
Brush brushCommon = new SolidBrush(Color.Purple);
Pen pen = new Pen(brushLeft, 10);
Rectangle leftVenn = new Rectangle(20, 50,100,100);
Rectangle rightVenn = new Rectangle(90, 50, 100, 100);
Rectangle commonVenn = new Rectangle(100, 120, 100, 100);
Font stringFont = new Font("Times New Roman", 9);
e.Graphics.DrawString("Left:" + leftValue, stringFont, brushLeft, 10,70);
e.Graphics.DrawString("Right:" + rightValue, stringFont, brushRight, 90,70);
e.Graphics.DrawString("Common:" + commonValue,stringFont, brushCommon, 100,70);
// Fill ellipse on screen.
e.Graphics.FillEllipse(brushLeft, leftVenn);
e.Graphics.FillEllipse(brushRight, rightVenn);
e.Graphics.DrawEllipse(Pens.White, leftVenn);
e.Graphics.DrawEllipse(Pens.White, rightVenn);
我正在绘制两个椭圆,公共(public)部分需要不同的颜色。我不能使用任何图书馆。请帮忙。
最佳答案
你可以使用半透明的颜色,这样重叠部分的颜色就是两个圆圈的实际合成颜色
Brush brushLeft = new SolidBrush(Color.FromArgb(50, Color.Blue));
Brush brushRight = new SolidBrush(Color.FromArgb(50, Color.Red));
关于c# - 在 C# win Form 中创建维恩图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25541036/