简体   繁体   English

如何在图片框角上绘制圆角椭圆?

[英]How can I draw a filleeliipse on pictureBox corners?

I'm trying to draw one ellipse at 0,0 and it's working but on the other side at pictureBox1.Width it's not drawing anything :我试图在 0,0 处绘制一个椭圆并且它正在工作,但在另一侧的 pictureBox1.Width 它没有绘制任何东西:

private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.FillEllipse(Brushes.Purple, 0, 0, 5, 5);
            e.Graphics.FillEllipse(Brushes.Purple, pictureBox1.Width, 0, 5, 5);
        }

The result is one ellipse filled on the left side at 0,0 but on the right side nothing.结果是一个椭圆在左侧填充为 0,0,但在右侧什么都没有。 There should be small purple point also near the right yellow one.右边的黄色点附近也应该有小紫色点。

purple紫色的

And then to draw filled ellipse on all the 4 corners on the pictureBox1.然后在pictureBox1的4个角上绘制实心椭圆。

The result is one ellipse filled on the left side at 0,0 but on the right side nothing.结果是一个椭圆在左侧填充为 0,0,但在右侧什么都没有。 There should be small purple point also near the right yellow one.右边的黄色点附近也应该有小紫色点。

This is because it's off the screen a bit, you'll need to adjust the X coordinate.这是因为它离屏幕有点远,您需要调整X坐标。

 e.Graphics.FillEllipse(Brushes.Purple, pictureBox1.Width - 5, 0, 5, 5);

在此处输入图片说明

If you'd like all four corners:如果您想要所有四个角:

 int circleSize = 5;

 e.Graphics.FillEllipse(Brushes.Purple, 0, 0, circleSize, circleSize); //top left
 e.Graphics.FillEllipse(Brushes.Purple, pictureBox1.Width - circleSize, 0, circleSize, circleSize); //top right
 e.Graphics.FillEllipse(Brushes.Purple, pictureBox1.Width - circleSize, pictureBox1.Height - circleSize, circleSize, circleSize); //bottom right
 e.Graphics.FillEllipse(Brushes.Purple, 0, pictureBox1.Height - circleSize, circleSize, circleSize); //bottom left

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

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