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

Allow custom BlendingState on EllipseGraphics #7541

Closed
nitzanmo opened this issue Feb 5, 2019 · 1 comment
Closed

Allow custom BlendingState on EllipseGraphics #7541

nitzanmo opened this issue Feb 5, 2019 · 1 comment

Comments

@nitzanmo
Copy link

nitzanmo commented Feb 5, 2019

Hi,
I'm currently working on an application which should draw multiple ellipses one on on top of the other, each with its own outline.

However, when ellipses collide, the collided section's translucency (alpha levels) increase until the terrain is hidden.

Screenshot:
unnamed 1

I have found a solution to this problem (And am aware that the solution is already implemented with other geometric shapes, e.g rectangle and circle), but it required:

  1. Creating a custom blending mode:
 CUSTOM_BLEND: freezeObject({
            enabled : true,
            equationRgb : BlendEquation.**MAX**,
            equationAlpha : BlendEquation.ADD,
            functionSourceRgb : BlendFunction.SOURCE_ALPHA,
            functionSourceAlpha : BlendFunction.SOURCE_ALPHA,
            functionDestinationRgb : BlendFunction.ONE_MINUS_SOURCE_ALPHA,
            functionDestinationAlpha : BlendFunction.ONE_MINUS_SOURCE_ALPHA
        }),
  1. Returning the custom blending mode when translucency is true, instead of the hardcoded ALPHA_BLEND.
    (Code section: )

    /**
     * Creates a render state.  This is not the final render state instance; instead,
     * it can contain a subset of render state properties identical to the render state
     * created in the context.
     *
     * @returns {Object} The render state.
     */
    Appearance.prototype.getRenderState = function() {
        var translucent = this.isTranslucent();
        var rs = clone(this.renderState, false);
        if (translucent) {
            rs.depthMask = false;
            rs.blending = BlendingState.**CUSTOM_BLEND**;
        } else {
            rs.depthMask = true;
        }
        return rs;
    };

After the change :

unnamed

An option to pass a custom blending state would be a better solution to the problem.

However, this is not the optimal solution since it fixates the alpha levels of the collided section.

@OmarShehata
Copy link
Contributor

Thanks for explaining your use case here @nitzanmo ! I'm closing this so we can keep discussion in the issue here: #7203

And we have a link to this issue from the other one further elaborating your use case.

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