Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(polyline): support drawMode: lines #1098

Open
wants to merge 2 commits into
base: v6
Choose a base branch
from
Open

feat(polyline): support drawMode: lines #1098

wants to merge 2 commits into from

Conversation

Ovilia
Copy link
Member

@Ovilia Ovilia commented Nov 12, 2024

The current implementation of Polyline supports only consecutive line segments, e.g. [[100, 10], [200, 20], [300, 33]] means lines from [100, 10] to [200, 20] and [200, 20] to [300, 33]. But if we want to draw non-consecutive lines like [100, 10] to [200, 20] and [400, 40] to [300, 33], we can only use two polylines, which is both more tedious to write and less efficient.

In this PR, I propose a new interface drawMode: 'lineStrip' | 'lines' for Polyline. Its default value is 'lineStrip', which ensures compatibility with the old API.

The concept is borrowed from OpenGL with GL_LINE_STRIP (continuous series of connected line segment) GL_LINES (treating every pair of vertices as an independent line segment).

new zrender.Polyline({
    shape: {
        points: [
            [400, 50],
            [500, 100],

            [500, 200],
            [600, 400],

            [600, 400],
            [500, 350],

            [500, 350],
            [400, 400]
        ],
        drawMode: 'lines',
        smooth: 0.8
    }
});

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants