Skip to content

Clip leaks when used in an "on background layer" scope? #1419

@Rmano

Description

@Rmano

Brief outline of the bug

It seems that when using a scope with on background layer, the clipping areas leak to other on background layer scopes unless it is protected by another scope.

I am not sure if this is expected behavior or not.

Minimal working example (MWE)

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[]
    \draw (0,0) rectangle (1,1);
    \begin{scope}[on background layer]
        \begin{scope}
            \clip (0,0) rectangle (1,1);
            \filldraw[yellow] (0,0) circle[radius=1cm];
        \end{scope}
    \end{scope}
    \begin{scope}[on background layer]
        \begin{scope}
            \clip (-1,-1) rectangle (1,1);
            \filldraw[orange] (0,0) circle[radius=.2cm];
        \end{scope}
    \end{scope}
\end{tikzpicture}
\end{document}

results in

Image

with correct clipping, but if you comment out the inner scope environments, you get:

Image

In both, I am a bit surprised by the bounding box, though.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions