B4A Library Morphos

A (partly) wrap for this Github project. Posing the following:
1. B4A sample project
2. Library files - copy then to your additional libs folder
3. The Java code

You can use it with any B4A view that has been added via the designer or via code

Library
Morphos
Author:
Github: Ricardo Vieira, Wrapped by: Johan Schoeman
Version: 1
  • Morphos
    Events:
    • animation_started () As , animation_stopped( As )
    Methods:
    • Alpha (view As View, value As Double, duration As Int)
    • Dimensions (view As View, width As Float, height As Float, duration As Int)
    • Initialize (EventName As String)
    • Reset
    • Reverse
    • Rotation (view As View, degrees As Double, duration As Int)
    • RotationXY (view As View, valueX As Float, valueY As Float, duration As Int)
    • Scale (view As View, valueX As Double, valueY As Double, duration As Int)
    • Translation (view As View, valueX As Float, valueY As Float, valueZ As Float, duration As Int)
    • TranslationX (view As View, valueX As Float, duration As Int)
    • TranslationY (view As View, valueY As Float, duration As Int)

Sample Code
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aMorphos
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    Dim panelmorph As Morphos
    Dim p1 As Panel
   
    Private iv1 As ImageView
    Private l1 As Label
    Dim cnt As Int  = 0

    Dim xpos, ypos As Int
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
   
    panelmorph.Initialize("pnl")
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub p1_click
   
        If cnt = 0 Then
          xpos = p1.Left
          ypos = p1.Top
          panelmorph.Translation(p1, 200, 100, 0, 1500)
        End If 
   
End Sub



Sub pnl_animation_started()
   

   
End Sub

Sub pnl_animation_stopped()
   
    cnt = cnt + 1
    Log("cnt = " & cnt)
    If cnt = 1 Then
        panelmorph.Translation(p1, xpos, ypos, 0, 1500)
    End If
   
    If cnt = 2 Then
        panelmorph.Alpha(p1, 0, 1500)
    End If
   
    If cnt = 3 Then
        panelmorph.Alpha(p1, 100, 1500)
    End If
   
    If cnt = 4 Then
        panelmorph.RotationXY(p1, 45, 45, 1500)
    End If
   
    If cnt = 5 Then
        panelmorph.RotationXY(p1, 0, 0, 1500)
    End If
   
    If cnt = 6 Then
        panelmorph.RotationXY(p1, -45, -45, 1500)
    End If
   
    If cnt = 7 Then
        panelmorph.RotationXY(p1, 0, 0, 1500)
    End If
   
    If cnt = 8 Then
        panelmorph.TranslationY(p1, 300, 1500)
    End If
   
    If cnt = 9 Then
        panelmorph.Rotation(p1, 720, 1500)
    End If
   
    If cnt = 10 Then
        panelmorph.Rotation(p1, -720, 1500)
    End If
   
    If cnt = 11 Then
        panelmorph.TranslationY(p1, ypos, 1500)
    End If
   
    If cnt = 12 Then
        panelmorph.TranslationX(p1, Activity.Width - p1.width, 1500)
    End If
   
    If cnt = 13 Then
        panelmorph.TranslationY(p1, Activity.Height - p1.Height, 1500)
    End If
   
    If cnt = 14 Then
        panelmorph.TranslationX(p1, 0, 1500)
    End If
   
    If cnt = 15 Then
        panelmorph.TranslationY(p1, 0, 1500)
    End If
   
    If cnt = 16 Then
        panelmorph.Translation(p1, xpos, ypos, 0, 1500)
    End If
   
    If cnt = 17 Then
        panelmorph.RotationXY(iv1, 45, 45, 1500)
    End If
   
    If cnt = 18 Then
        panelmorph.RotationXY(iv1, 0, 0, 1500)
    End If
   
    If cnt = 19 Then
        panelmorph.RotationXY(iv1, -45, -45, 1500)
    End If
   
    If cnt = 20 Then
        panelmorph.RotationXY(iv1, 0, 0, 1500)
    End If
   
   
    If cnt = 21 Then
        cnt = 0
    End If
   
   
End Sub

Take it for a test drive....
 

Attachments

  • b4aLibraryFiles.zip
    35.8 KB · Views: 281
  • TheJavaCode.zip
    55.7 KB · Views: 250
  • b4aMorphos.zip
    266.2 KB · Views: 265
Top