Quick Links: Gideros Home | Download Gideros | Developer Guide
How to create colour gradient for shadow?
  • snooks +1 -1
    I need to add a shadow to my navigation drawer implementation, I see that a Pixel can be created with a gradient but it's not clear to me how it is intended to be used. Could anybody shine some light on this?
  • snooks +1 -1
    I'm back to this issue and Pixel doesn't allow setting a relative alpha amount after setting the alpha for the corners. So Pixel:setAlpha() doesn't do anything. It also doesn't follow the alpha channel of the parent.

    Can I draw it offscreen and create a Texture from it?
  • antixantix +1 -1
    Maybe @hgy29 or somebody more familiar with Pixels can help out. Maybe a mesh would work.

    Is this gradient supposed to be a rectangle?
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • snooks +1 -1
    Yes, it's 5 logical pixels wide going from black, alpha 1 to black alpha 0 and it's the full height of the screen.
  • hgy29hgy29 +1 -1
    Can't you use http://docs.giderosmobile.com/reference/gideros/Pixel/setColor2#Pixel:setColor ?
  • snooks +1 -1
    Yes, that's what I have done, but I want to tween the first alpha when opening/closing with fling gestures or with open/close methods. For just manual dragging that would work fine.
  • hgy29hgy29 +1 -1 (+1 / -0 )
    Looks like a gideros bug to me, Pixel should have honored setAlpha() setting.
    It looks like the shader doesn't multiply gradient color by constant color multiplier.
    Those color shaders are only used by Mesh (when supplying a color array) and Pixel (when using gradient), so maybe this bug wasn't noticed before.

    Try replacing the default shader and see if it helps:
    local shader=Shader.new([[
    attribute lowp vec4 vColor;
    attribute highp vec3 vVertex;
    uniform lowp vec4 fColor;
    uniform highp mat4 vMatrix;
    varying lowp vec4 fInColor;
    void main() {
    vec4 vertex = vec4(vVertex,1.0);
    gl_Position = vMatrix*vertex;
    varying lowp vec4 fInColor;
    void main() {
    gl_FragColor = fInColor;

    Another method would be to call setColor() on the pixel on each tween step to adjust the gradient values manually.

    Likes: antix

  • snooks +1 -1
    Yes, that's it - thanks for that! And my skill of finding at least one bug in mature products within days remains strong! With the new shader I can set the alpha channel of the Pixel and it respects changes in the alpha channel of the parent.

    Speaking of shadows and shaders, where would the best resource be for seeing how to implement a diffuser (or whatever is best) for diffusing grey/black rects for general pop up/UI shadows? To implement this..


    ... which would be easy with CSS...


    ,,, ?
  • @snook it looks interesting :)

    I believe that development a widget with the concept Material Design, It could be a great feature for Gideros about all in business, social or educational app development.

    Honestly, I think about it, but currently I haven't wrote some code for Material Design yet maybe when I finished some projects I'll take this matter.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters