processing / processing/processing4

PShape does not provide getters for rectMode / ellipseMode

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

还没有人认领这个 Issue。

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

描述

Most relevant area for this enhancement?

Core/Environment/Rendering

Feature to enhance

The PShape class

Enhancement details
Enhancement description

I was half way developing some classes to convert between PShapes and OPENRNDR Shapes but got stuck.

When dealing with PShape.PRIMITIVE types, PShape.getKind() returns what kind of shape is it (rect, ellipse, ...) and the PShape.getParams() returns an array of float values (x, y, width...) One needs to know the kind to know what the float values mean. But it's not sufficient, because if one called ellipseMode before, the values may mean center x and y, or corner x and y, either width or radius.

I didn't find a way to query ellipseMode or rectMode.

Benefits

Adding a way to query this information would help cross framework use of the PShape data structures.

Challenges

I think adding two getters to PShape shouldn't have any negative impact, but I'm not very familiar with the code base to be sure.

Additional context

Here a wip function where I try to convert an ELLIPSE PShape to an OPENRNDR Shape. This is incomplete, because the meaning of params 0, 1, 2 and 3 depend on the ellipseMode used, and there's no way to figure this out (I think).

        PShape.PRIMITIVE -> {
            listOf( // 101
                when (kind) {
                    PShape.RECT -> Rectangle( // 30
                        params[0] * 1.0, params[1] * 1.0,
                        params[2] * 1.0, params[3] * 1.0
                    ).contour

                    PShape.ELLIPSE -> Ellipse( // 31
                        params[0] * 1.0, params[1] * 1.0,
                        params[2] * 0.5, params[3] * 0.5
                    ).contour

                    PShape.LINE -> LineSegment(
                        params[0] * 1.0, params[1] * 1.0,
                        params[2] * 1.0, params[3] * 1.0
                    ).contour

                    // ARC, TRIANGLE, QUAD, SPHERE, BOX
                    else -> error("unsupported primitive kind: $kind")
                }
            )

PShape holds ellipseMode and rectMode variables, but they are protected and without getters.

Would you like to help implement this enhancement?

I’m not sure yet

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 PShape 类开始,检查受保护的 ellipseMode 和 rectMode 字段以及其现有的公共 API。添加一种让调用方能够查询这两种模式的方式,然后验证基本图形转换代码能够区分每种模式下参数的含义。

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

评估

技术栈
java
领域
computer-graphics
Issue 类型
功能
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

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