小编Rap*_*ock的帖子

如何设置圆形画布边框的颜色

我使用 canvas 2D 在 QML 中创建了圆圈。半圆有浅绿色和另一半天蓝色,但现在我不知道如何设置该圆的边框颜色。有人知道如何设置这个圆的边框颜色吗?

     Canvas {
          anchors.fill: parent
          onPaint: {
              var ctx = getContext("2d");
              ctx.reset();

              var centreX =900;
              var centreY = 150;

              ctx.beginPath();
              ctx.fillStyle = "#16AA55"; //green
              ctx.moveTo(centreX, centreY);
              ctx.arc(centreX, centreY,100, Math.PI * 0.01, Math.PI * 1, false);
              ctx.lineTo(centreX, centreY);
              ctx.fill();

              ctx.beginPath();
              ctx.fillStyle = "#26A7CA";
              ctx.moveTo(centreX, centreY);
              ctx.arc(centreX, centreY, 100, Math.PI * 1, Math.PI * 2.01, false);
              ctx.lineTo(centreX, centreY);
              ctx.fill();
          }
Run Code Online (Sandbox Code Playgroud)

html canvas qml

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

canvas ×1

html ×1

qml ×1