Skip to content

Conversation

@r3kste
Copy link
Contributor

@r3kste r3kste commented Dec 4, 2025

PR summary

closes #30547

This PR enhances the API of draw_path_collection() for long term maintainability.

Summary of Changes

  1. Introduces the new VectorizedGraphicsContextBase class, which is similar to GraphicsContextBase, but each attribute is vectorized. This serves as the dataclass through which all parameters are passed to draw_path_collection().

  2. Updated signature of draw_path_collection() by making the parameters optional in order to support both the following:

    • The previous call with gc and all parameters present
    • The new call with vgc and none of the optional parameters
  3. Updated signature of _iter_collection() to take vgc instead of gc and added logic to cycle through all attributes.

  4. Changed draw() in Collection to use the new draw_path_collection() API along with temporary fallback for third-party backends that use the old signature.

Why is this change required?

It would become much simpler to add / vectorize new attributes in collections, without completely breaking third party backends. For example, it would greatly simplify #27937, that aims to vectorize the hatch attribute.

To-do

  • Docstrings
  • What's new note
  • Deprecation notice for the old API

PR checklist

Co-authored-by: Pranav <kingprawn5000@gmail.com>
Co-authored-by: AdwaithBatchu <adwaithbatchu@gmail.com>
Co-authored-by: Sreekanth-M8 <kmsreekanthsai@gmail.com>
Co-authored-by: Sujal Kumar <sujaljayantkumar06@gmail.com>
@r3kste r3kste force-pushed the draw_path_collection_refactor branch from 195e00e to a1ba476 Compare December 4, 2025 21:29
@timhoffm
Copy link
Member

timhoffm commented Dec 7, 2025

Thanks for the PR. I‘d like to hold this off until #30777 is in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MNT]: Revamp draw_path_collection() API

3 participants