question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stencil cancelled on intersection of shapes

See original GitHub issue

Hi,

When we use the StencilPush instructions, if we want to define the stencil as a complex shape like a trianle and an ellipse together, on the intersection of the two shapes, the stencil will simply be cancelled.

Example :

    StencilPush
    Color:
        rgba: 1, 0, 0, 1
    Rectangle:
        pos: 50,50
        size: 20, 20
    Ellipse:
        pos: 50, 55
        size: 15, 15
    ... then all the other stencil instructions...

Expected behaviour : a stencil of the shape of a square.

It actually happen no matter what type of shape we draw in the StencilPush : line, quad, etc. …

The is VERY problematic because it only allow us to use simple shapes or to compute intersection and draw complex shapes instead of simple ones to avoid intersection.

Especially if the stencil position if moving (like the sight of a player in the dark) and we have another shape somewhere on the canvas (let’s say a spot light) then everything will work at the begining… and stop working properly when intersection of the two shapes will happen.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
titocommented, Nov 20, 2012

The demo is working for what you asked for, but it has a bug cause of a nested usage of Stencil (Done by StencilView here.)

So basically, setting func_op should work for this case, except if you use it inside another widget that use Stencil. (then you might have issues). Sorry about that!

I’ve thinked more about a “mask” possibility, using Fbo + Shader:


# THIS IS NOT WORKING NOR IMPLEMENTED, just sharing my mind
canvas:
    Fbo:
        size: root.size
        id: fbo_mask

        # thoses instructions will be added directly on the Fbo, not on the canvas.
        Rectangle:
            pos: 20, 20
            size: 50, 50
        Ellipse:
            pos: 60, 60
            size: 40, 40

    Mask:
        mask: fbo_mask #(should be a texture, but in an fbo is passed, then the fbo.texture is used.)
        pos: root.pos
        size: root.size

        # theses instruction will be added on the Mask, not on the canvas
        # the Mask instruction will contain a shader that use the mask texture as a "stencil"
        Color:
            rgb: 1, 1, 1
        Rectangle:
            pos: 0, 0
            size: 100, 100
            source: 'data/logo/kivy-icon-512.png'
0reactions
tdubourgcommented, Mar 17, 2013

Hi Tito,

Sorry for the late reply. So I tested your solution and it is… nearly working.

In fact, it does work when using the KV language, but it does not when using the same instructions from Python directly… Which is, well, an issue because KV part is quite “static” (unless we generate it on the fly and pass it to the Builder but I can help but think of that as nasty).

If you need a demo of non-working code when used from Python vs. Working code when used from KV, tell me. But basically the example code you provided - transcripted to full-python calls code - is enough to spot the bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

New Stencil Collection- Overlapping Shapes! - Carolyn Dube
This Overlapping Shapes collection is an exploration of the idea that everything is connected. It symbolizes the moments and places where things overlap...
Read more >
Edit connector lines, arrows, or points - Microsoft Support
Select a connector. On the Home tab, in the Shape group, select Line, and then select Line Options. In the Line window select...
Read more >
Capital Electra X: Advanced shape operations
Advanced shape operations. ... Select 2 or more shapes, then right click and select Operations | Intersect. Intersect shapes How to intersect shapes ......
Read more >
Masking effects in PowerPoint: Creating stencils - BrightCarbon
Unlock the power of using shapes as stencils in PowerPoint. ... Then, select the top image and your shape, and use the “Intersect”...
Read more >
How to Merge Shapes in PowerPoint (Union, Intersect, Subtract)
Create compelling diagrams in PowerPoint using the Merge Shapes functionality, apply Union, Intersect and Substract operation to your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found