Sviluppatori Basic (e non) per Mobile e Desktop

Forum dedicato agli sviluppatori di B4X, Delphi, Xamarin


Non sei connesso Connettiti o registrati

Effetto luce

Andare in basso  Messaggio [Pagina 1 di 1]

1 Effetto luce il Gio Mag 03, 2018 11:18 pm

Dust

avatar
Admin
Admin
Codice:

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim xui As XUI
   Private Label1 As Label
   Dim PanelMask As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Label1.Initialize("Label1")
   PanelMask.Initialize("")
   Activity.Addview(Label1,0,0,100%x, 120dip)
   Activity.Addview(PanelMask,0,0,100%x, 120dip)
   
   Label1.Text="@LucaMS"
   Label1.TextColor=Colors.Blue
   Label1.Gravity=17
   Label1.TextSize=56
   
   CreateMask
End Sub

Sub Label1_Click
   Light2(Sender,600)
End Sub

Sub Label2_Click
   Light2(Sender,600)
End Sub

Sub Light2(ImageView As B4XView, Delay As Int)
   Dim xui As XUI
   Dim PanelBase As B4XView = xui.CreatePanel("")
   Dim PanelEffect As B4XView = xui.CreatePanel("")
            
   PanelBase.BringToFront
   ImageView.Parent.AddView(PanelBase,ImageView.Left,ImageView.Top,ImageView.Width,ImageView.Height)
   PanelBase.AddView(PanelEffect,-200DIP,-150dip,100dip,PanelBase.Height+300dip)
   PanelMask.BringToFront
   
   Dim Can As B4XCanvas
   Dim MaxW As Int = PanelEffect.Width-1
   
   Can.Initialize(PanelEffect)
   
   For x=0 To MaxW
      Dim C As Int = 200*(1-Sin(cPI*(((x+MaxW/2) Mod MaxW)/MaxW)))
      Can.DrawLine(x,0,x,PanelEffect.Height,xui.Color_ARGB(C,255,255,255),1dip)
   Next
   PanelEffect.Rotation=45
   
   PanelEffect.SetLayoutAnimated(Delay,PanelBase.Width*1.8,0,PanelEffect.Width,PanelEffect.Height)
   
   Can.Invalidate
   Sleep(Delay)
   Can.Release
   PanelBase.RemoveViewFromParent
End Sub

Sub CreateMask
   ' B4A function
   Dim Lb4x As B4XView = Label1
      
   Dim Out As OutputStream
   Out = File.OpenOutput(xui.DefaultFolder, "Test.png", False)
   Lb4x.Snapshot.WriteToStream(Out, 100, "PNG")
   Out.Close
   Dim Bt As Bitmap = LoadBitmap(xui.DefaultFolder, "Test.png")
         
   PanelMask.BringToFront
   Dim Canv As Canvas
   Canv.Initialize(PanelMask)
   For x=0 To Bt.Width-1
      For y=0 To Bt.Height-1
         'Log(Bt.GetPixel(x,y))
         If Bt.GetPixel(x,y)=0 Then
            Canv.DrawPoint(x,y,Colors.Black)
         Else
            Canv.DrawPoint(x,y,Colors.Transparent)
         End If
      Next
   Next
End Sub

Visualizza il profilo http://basic4x.forumattivo.com

Torna in alto  Messaggio [Pagina 1 di 1]

Permessi di questa sezione del forum:
Non puoi rispondere agli argomenti in questo forum