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

PathCollection doesn't document cap and join styles #306

Open
kennykb opened this issue Nov 13, 2022 · 5 comments
Open

PathCollection doesn't document cap and join styles #306

kennykb opened this issue Nov 13, 2022 · 5 comments

Comments

@kennykb
Copy link
Contributor

kennykb commented Nov 13, 2022

I have an issue (attachment shows a reduced demonstration) where the miters of joined line segments in a PathCollection extend unreasonably far when the angle between them grows acute (use the trackball to rotate the figure in the demo to see the behaviour).

Changing the miter_limit parameter appears to have no effect.

I suspect that the cap and join parameters are necessary to confine the extension of the lines, but I've not found any documentation on what values they take. I haven't yet had time to decipher the complex shader code to figure it out.

I'd be happy to contribute a PR to elucidate this, but first I need to understand it myself!
miters.zip

@rougier
Copy link
Member

rougier commented Nov 28, 2022

Sorry for late reply. Can you post a screenshot to show the problem (just drag and drop images in the issue)

@kennykb
Copy link
Contributor Author

kennykb commented Nov 28, 2022

Screenshot and script that generated it are in the attached ZIP

@rougier
Copy link
Member

rougier commented Dec 5, 2022

Easier for me if you post here.

@kennykb
Copy link
Contributor Author

kennykb commented Dec 6, 2022

Script:

from glumpy import app, gl, glm, gloo, graphics, transforms
from glumpy.graphics.collections import PathCollection
from glumpy_cardboard_box import CardboardBox
import numpy as np

# Get the scale for our box and the size of an enclosing sphere. Give an
# initial value for the camera distance

h, w, d = 27.72, 20.78, 6.95
radius = 0.5 * np.linalg.norm([h, w, d]);
distance = 6.0 * radius

# Start up Glumpy

winWidth = 1920
winHeight = 1080
window = app.Window(width=winWidth, height=winHeight,
                    color=(0.0, 0.0, 0.25, 1.00))
@window.event
def on_init():
    gl.glEnable(gl.GL_BLEND)
    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glPolygonOffset(1, 1)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glLineWidth(0.75)

@window.event
def on_draw(dt):
    window.clear()
    paths.draw()

vertices = np.array([[-1, -1, -1],
                     [-1, -1, 1],
                     [-1, 1, 1],
                     [-1, 1, -1],
                     [1, 1, -1],
                     [1, 1, 1],
                     [1, -1, 1],
                     [1, -1, -1],
                     [0, -1, -1]], dtype=np.float32)
scale = np.diag([w, -d, h])/2
vertices = vertices @ scale

transform = transforms.Trackball(transforms.Position())
viewport = transforms.Viewport()
paths = PathCollection("agg", transform=transform, viewport=viewport,
                       color='shared', linewidth='shared',
                       miter_limit='shared')

paths.append(vertices, color=[1, 1, 0, 1], linewidth=3, miter_limit=0.1)

window.attach(transform)
window.attach(viewport)

transform["distance"] = distance
transform["theta"] = 60.0
transform["phi"] = -30.0

app.run()

Using the trackball can result in images like:
segmentsonly

@rougier
Copy link
Member

rougier commented Dec 20, 2022

Miter limit is used here and might be wrong. Is the path ok with round joins ? To ease debugging, best would be to have a two segment paths in ortho mode that show the problem.

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

No branches or pull requests

2 participants