Processing 绘制边框/轮廓(即镂空形状)的方法

tags: Processing

想绘制一个类似像框这种内部镂空的形状,类似 Photoshop 里的遮罩效果。“回”字图或“O”字图。尝试了一下。

环境:Processing 3.x

方法1:画线,调整线的宽度

示例代码:

//方法1代码示例

size(200, 200);
noFill();
float w=20;
stroke(255, 0, 0);
strokeWeight(w);
ellipse(width/2, height/2,100,100);
stroke(255);
strokeWeight(1);
ellipse(width/2, height/2,100-w,100-w);
ellipse(width/2, height/2,100+w,100+w);

效果图:
方法1效果图

方法2:画轮廓线 beginContour()

Processing 内置提供了轮廓线方法。案例参考:

// code from: https://processing.org/reference/beginContour_.html
size(100, 100);
translate(50, 50);
stroke(255, 0, 0);
beginShape();
// Exterior part of shape, clockwise winding
vertex(-40, -40);
vertex(40, -40);
vertex(40, 40);
vertex(-40, 40);
// Interior part of shape, counter-clockwise winding
beginContour();
vertex(-20, -20);
vertex(-20, 20);
vertex(20, 20);
vertex(20, -20);
endContour();
endShape(CLOSE);

效果:

方法2效果图

beginShape() 开始画自定义图形,先画外轮廓线,然后 beginContour() 开始画内轮廓线。

注意:外轮廓线,顺时针给坐标。内轮廓线,逆时针给坐标

[正文结束]


[更新记录]
2016-10-14,初建笔记。记录了 storkeWeight 和 beginContour 2种方法

转载于:https://www.cnblogs.com/buchiany/p/6426422.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值