processing / processing/processing4

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

Đang mở
#1,191 4 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Java
Star
494
Fork
183
Merge trung bình
4 giờ 39 phút
Pull request đã merge (30 ngày)
3

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong khu vực Core/Environment/Rendering bằng cách đọc hành vi hiện có của mask() và tài liệu tham chiếu beginClip() được liên kết của p5.js. Xác định beginClip(), endClip() và cờ invert tùy chọn sẽ hoạt động như thế nào, sau đó xác minh rằng các lệnh vẽ giữa các lần gọi tạo ra hành vi cắt thông thường và đảo ngược như mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
computer-graphics
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.