processing / processing/processing4

Add `beginClip()` and `endClip()` masking functions

未关闭
#1,191 4 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
494
派生
183
平均合并
4 小时 39 分钟
30 天内合并 PR
3

描述

Relevant sub-area for this feature?

Core/Environment/Rendering

Feature details
Feature description

Add beginClip() and endClip() to define clipping masks using drawing commands. Shapes drawn between these calls become the mask. An optional invert flag enables inverse masking.

Benefits
  • More intuitive and less verbose than mask()
  • Matches p5.js API and reduces cognitive load when switching from one to the other
Challenges
  • Not sure
Additional context

See https://p5js.org/reference/p5/beginClip/

Example code

This mask() code...

  // Create pattern graphics
  pattern = createGraphics(width, height);
  pattern.beginDraw();
  pattern.background(255);
  pattern.stroke(0);
  pattern.strokeWeight(2);
  for (int x = 0; x < width; x += 10) {
    pattern.line(x, 0, x, height);
  }
  pattern.endDraw();

  // Create mask graphics (white circle on black)
  maskImg = createGraphics(width, height);
  maskImg.beginDraw();
  maskImg.background(0);
  maskImg.noStroke();
  maskImg.fill(255);
  maskImg.ellipse(width/2, height/2, 200, 200);
  maskImg.endDraw();

  // Apply mask to pattern
  pattern.mask(maskImg);

... becomes this using beginClip()/endClip():

  // Define clipping region
  beginClip();
  ellipse(width/2, height/2, 200, 200);
  endClip();

  // Draw pattern inside the clip
  stroke(0);
  strokeWeight(2);
  for (int x = 0; x < width; x += 10) {
    line(x, 0, x, height);
  }
Would you like to help implement this feature?

No, I’m just suggesting the feature

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Core/Environment/Rendering 区域开始,阅读现有的 mask() 行为以及链接的 p5.js beginClip() 参考。定义 beginClip()、endClip() 和可选的 invert 标志应如何工作,然后验证两次调用之间的绘图命令是否产生预期的正常和反向裁剪行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
computer-graphics
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。