StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
284 stars 89 forks source link

Stroke alpha - drawing with lineStyle on shape graphics #90

Open andrewskorik opened 10 years ago

andrewskorik commented 10 years ago

stroke alpha isn't used. upd: * - drawing with lineStyle on shape graphics

IonSwitz commented 10 years ago

In what scenario?

In this scenario, both the alpha supplied in the addVertex method call, and the alpha set on the stroke itself result in transparency, and yield expected results.

        var stroke:Stroke = new Stroke();
        stroke.addVertex(100, 100, 1, 0xFFFFFF, 0, 0xFFFFFF, 0);
        stroke.addVertex(150, 150);
        stroke.addVertex(250, 200);
        stroke.addVertex(250, 200);
        stroke.addVertex(400, 300);
        stroke.addVertex(400, 400, 1, 0xFFFFFF, 0, 0xFFFFFF, 0);
        stroke.alpha = 0.3;
        addChild(stroke);

Do you have an example where the alpha isn't used?

AlBirdie commented 10 years ago

Alpha is working properly for me as well. Never had an issue with that.

andrewskorik commented 10 years ago

var sh:Shape = new Shape () addChild (sh); ... sh.graphics.clear(); sh.graphics.lineStyle((1/scale) * thickness, 0x325d63, 0.2); sh.graphics.drawCircle(0, 0, radius); sh.graphics.endFill ();

Circle drawed with full 1.0 alpha. seems sh.alpha = 0.2 also don't affects this.

IonSwitz commented 10 years ago

Ok, thank you for reporting this.

I will look into this asap. Always easier with a test case to find the problem :)

EDIT: Not knowing your values for "scale", "thickness" and "radius", I replaced those with static values. In this test case, alpha works flawlessly:

var sh:Shape = new Shape (); addChild (sh);

sh.graphics.clear(); sh.graphics.lineStyle(3, 0x325d63, 0.6); sh.graphics.drawCircle(200, 200, 80); sh.graphics.endFill ();

Also, setting the alpha value on the Shape works for me too:

sh.alpha = 1; v.s. sh.alpha = 0;

Yield a visible v.s an invisible circle.

Are you running off the SWC or off the source tree?

andrewskorik commented 10 years ago

:) thank you! Nice extension anyway!

IonSwitz commented 10 years ago

Thanks for using and enjoying the extension and for reporting issues :)

As I wrote above here, I am unable to reproduce the problem, using the static scale, thickness, and radius values above.

What platform are you running on? I don't have a mobile platform to run on, but in a Windows Flash Player, the code works fine.

andrewskorik commented 10 years ago

Flex app with starling scene. It's have nested structure.. shape placed in several nested sprites, and root sprite is scaled. drawing on shape graphics done with 1/scale to achive correct thickness of lines on screen. screenshot from app image

For now i used another color of lines, to compensate alpha :)

System info : Capabilities playerType:"StandAlone", version:"WIN 12,0,0,38", screenColor:"color", isEmbeddedInAcrobat:false, language:"ru", hasEmbeddedVideo:true, screenDPI:72, hasAudio:true, screenResolutionX:1920, avHardwareDisable:false, screenResolutionY:1080, hasAccessibility:false, touchscreenType:"none", hasAudioEncoder:true, pixelAspectRatio:1, hasMP3:true, hasTLS:true, hasPrinting:true, maxLevelIDC:"5.1", hasScreenBroadcast:false, supports32BitProcesses:true, hasScreenPlayback:false, supports64BitProcesses:false, hasStreamingAudio:true, hasIME:true, hasStreamingVideo:true, hasVideoEncoder:true, prototype:{Object }, isDebugger:true, localFileReadDisable:false, manufacturer:"Adobe Windows", _internal:4, os:"Windows 7", cpuArchitecture:"x86"}

IonSwitz commented 10 years ago

Could you please check what the values of scale, thickness and radius is in your example? If I get the same values that you use when things don't work, maybe I will be able to get a reproduction case on my machine as well...

Oh, and also, I see that you use Flash Player 12. I am using 11.9. Would it be hard for you to run it in Flash Player 11.8 or 11.9? I am on my work computer now, and am unable to run FP 12.

andrewskorik commented 10 years ago

tested on 11.8 - same result. added another shape to root without any scale - and catched strange results with 1px width - it looks as stroke without any smoothing.. but if I increase value to 10 px

var sh:Shape = new Shape (); sh.graphics.lineStyle(10, 0xffffff, 0.1); sh.graphics.drawCircle(400,400,200); sh.graphics.endFill(); addChild(sh);

It's look like gradient-filled stroke

image

andrewskorik commented 10 years ago

same with lines in scaled nested shape if i increase value

sh.graphics.lineStyle((1/scale) * 10, 0x325d63, 0.2);

image

seems it's not scale or something else issue..

IonSwitz commented 10 years ago

Not sure why I didn't ask this before, but why the endFill, when you do not have a beginFill of any kind?

andrewskorik commented 10 years ago

old stupid habit :) but not sure if this has effect

IonSwitz commented 10 years ago

Could you check if you have any filters applied to any displayObjects in the parent chain? I really am unable to reproduce this, even if I create a object hierarchy and set scaling etc on the parent objects. Have you used "flatten" on any parent Sprites? Anything like that?

For me: the strokes that gets drawn are uniform in color, with the same alpha set over the entire Shape. :(

I mean, I guess that's good, but it's super annoying to not be able to reproduce a problem :)

andrewskorik commented 10 years ago

Hi, ok I will try to isolate this and provide sample. No, filters not used. I've used blend mode "SCREEN" on underlaying texture pattern (several layers with stars on bg) And yes. Active stars - flattened (sprites with image and textfield)

ó Õ×ÁÖÅÎÉÅÍ, óËÏÒÉË áÎÄÒÅÊ. andrewskorik@gmail.com