B4J Code Snippet [B4X] [XUI] Light Effect

Discussion in 'B4J Code Snippets' started by Star-Dust, May 1, 2018.

  1. Star-Dust

    Star-Dust Expert Licensed User

    Have you ever thought of making a lighting effect on an image?
    If you do not, I thought about it ... this is a small code with a simple trick that allows you to get it with B4X

    Sub ImageView1_Click
    End Sub

    Sub ImageView2_Click
    End Sub

    Sub Light(ImageView As B4XView)
    Dim xui As XUI
    Dim PanelBase As B4XView = xui.CreatePanel("")
    Dim PanelEffect As B4XView = xui.CreatePanel("")
    Dim Dv as int = 3  ' effect width = mBase.Width/Dv


    Dim Can As B4XCanvas
    Dim MaxW As Int = PanelEffect.Width-1


    For x=0 To MaxW
    Dim C As Int = 255*(1-Sin(cPI*(((x+MaxW/2Mod MaxW)/MaxW)))


    End Sub
    ezgif.com-video-to-gif.gif [​IMG]

    Attached Files:

    Last edited: May 1, 2018
  2. Johan Hormaza

    Johan Hormaza Active Member Licensed User

  3. Erel

    Erel Administrator Staff Member Licensed User

    Great job!
  4. Star-Dust

    Star-Dust Expert Licensed User


    Who can reproduce this in B4X XUI.

    As usual LucaMS is not satisfied and has something to say, so he asked me for a change to the effect created, the reflection of light must hit only the writing and not the background and without losing speed.

    The view is a simple Label is not an Image, so you can change it as you wish.

    I made it in B4A, who can do it in B4X?

    LucaMs and Johan Hormaza like this.
  5. LucaMs

    LucaMs Expert Licensed User

    If you change the text to "Mario" I'm pretty sure it will work as it is on all platforms :p
  6. Star-Dust

    Star-Dust Expert Licensed User

    it is possible, the source code knows where to find it
    LucaMs likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice