Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

PShape does not provide getters for rectMode / ellipseMode

未關閉
#1,359 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
48/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
java

研究方向

從 PShape 類別開始,檢查受保護的 ellipseMode 和 rectMode 欄位以及其現有的公開 API。新增一種讓呼叫端能夠查詢這兩種模式的方式,然後確認基本圖形轉換程式碼能夠區分每種模式下參數的意義。

由索引模型根據 Issue 內容生成。

描述

enhancement
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

主要語言
Java
星號
497
分支
183
平均合併
4 小時 39 分鐘
30 天內合併 PR
3

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

processing/processing4 的其他 Issue

查看 processing/processing4 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。