hype / HYPE_Processing

HYPE for Processing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HCanvas displays incorrect alpha when autoClear is disabled

cadin opened this issue · comments

When using autoClear(false) on HCanvas, HDrawables with an alpha set seem to display at about half of the specified alpha value.

This simple sketch demonstrates the issue:

import hype.*;

HCanvas canvas;
HRect   rect;

void setup() {
    size(200,200);
    H.init(this).background(#ffffff);
    canvas = new HCanvas().autoClear(false);
    H.add(canvas);

    // Clearing the PGraphics will force proper alpha display 
    // canvas.graphics().clear();

    canvas.add( rect = new HRect(50) ).fill(#000000).alpha(128);
    noLoop();
}

void draw() {
    H.drawStage();
}

If you sample the rect color on screen you can see it's 25% gray instead of the expected 50%.
Setting autoClear(true) works as expected.

One workaround I found is to explicitly clear the PGraphics (see commented line above).

This wasn't a problem in Processing 2.x using the old PDE-based Hype. I've only noticed it since moving to Processing 3 and the lib-staging distro.

(I'm running Processing 3.3.7 on OS X)

Actually, I was wrong; autoClear(true) and graphics().clear() only seem to solve the issue if using a black fill. Running the same code above with a red fill still gives unexpected results in all cases.

alphacomparison

This seems to be at least partially a problem with PGraphics itself in Processing 3.

This seems to be a Processing issue, not a Hype issue:
processing/processing#3391

Thanks for reading!