简体   繁体   English

图形错误

[英]Error in Drawing Graphics

I have a bug with this code but it runs and I don't see where. 我的这段代码有一个错误,但是它可以运行,我看不到哪里。

System.Drawing.Graphics graphics = this.CreateGraphics();
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200);
graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle);
graphics.DrawRectangle(System.Drawing.Pens.Red, rectangle);

Check line 2 of your code. 检查代码的第2行。 You only having 3 dimensions instead of having four. 您只有3个维度,而不是4个。

System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, xyz);

You need at least 2 points (4 coordinates) to draw a rectangle, maybe you wanted to do 您至少需要2个点(4个坐标)才能绘制矩形,也许您想这样做

System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, x);

where x is the fourth coordinate (which you have to add)? x是第四个坐标(必须添加)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM