ps怎样做出一个矩形两边是椭圆形

1、第一步,选择一个举行选框工具

2、第二步选择椭圆选框工具

3、起点放到这里,摁住shift拖拽到这里

4、重复上面的操作,发现可以看到椭圆形

5、接下来新建图层,点击描边就出现了

6、成功了,O(∩_∩)O就是一点别扭

可以使用 `QPainterPath` 和 `QPainter` 绘制一个两边是圆弧的矩形,具体步骤如下: 1. 创建一个 `QPainterPath` 对象。 2. 使用 `QPainterPath` 的 `moveTo()` 方法将绘图起点移动到矩形左上角的位置。 3. 使用 `QPainterPath` 的 `lineTo()` 方法绘制出左边直线的路径。 4. 使用 `QPainterPath` 的 `arcTo()` 方法绘制出左上角圆弧的路径。 5. 使用 `QPainterPath` 的 `lineTo()` 方法绘制出上边直线的路径。 6. 使用 `QPainterPath` 的 `arcTo()` 方法绘制出右上角圆弧的路径。 7. 使用 `QPainterPath` 的 `lineTo()` 方法绘制出右边直线的路径。 8. 使用 `QPainterPath` 的 `arcTo()` 方法绘制出右下角圆弧的路径。 9. 使用 `QPainterPath` 的 `lineTo()` 方法绘制出下边直线的路径。 10. 使用 `QPainterPath` 的 `arcTo()` 方法绘制出左下角圆弧的路径。 11. 调用 `QPainter` 对象的 `fillPath()` 方法填充矩形。 下面是一个示例代码: ```cpp void MyWidget::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); painter.setBrush(Qt::red); int x = 50; int y = 50; int w = 200; int h = 100; int r = h / 2; QPainterPath path; path.moveTo(x + r, y); path.lineTo(x + w - r, y); path.arcTo(x + w - 2 * r, y, 2 * r, 2 * r, 90, -180); path.lineTo(x + r, y + h); path.arcTo(x, y, 2 * r, 2 * r, 270, -180); painter.drawPath(path); } ``` 在这个例子中,我们首先定义了矩形左上角的坐标 `(x, y)`,以及矩形的宽度 `w` 和高度 `h`。然后计算出圆弧的半径 `r`(这里取矩形高度的一半),并使用 `QPainterPath` 对象按照上述步骤绘制出两边是圆弧的矩形。最后,使用 `QPainter` 对象的 `drawPath()` 方法绘制出这个矩形
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱你三千遍斯塔克

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值