B4A Library ShapeRipple

A wrap for this Github project. Posting:
1. B4A library files
2. LibRes.zip - extract the zip file and copy the folder and its contents to be on the same folder level as that of the B4A project's /Objects and /Files folders
3. The Java code - change it to your liking
4. B4A sample project

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

#AdditionalRes: ..\LibRes

#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.

    Private sr1 As ShapeRipple
    Private sr2 As ShapeRipple
    Private sr3 As ShapeRipple
    Private sr4 As ShapeRipple
    Private sr5 As ShapeRipple
    Private sr6 As ShapeRipple
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")
   
    sr1.RippleDuration = 3000
    sr1.EnableSingleRipple = True
    sr1.RippleShape = sr1.SHAPE_CIRCLE
    sr1.EnableRandomColor = True
    sr1.EnableRandomPosition = False
    sr1.EnableColorTransition = True
    sr1.RippleStrokeWidth = 15
    sr1.EnableStrokeStyle = True
    sr1.RippleCount = 3
    sr1.RippleFromColor = Colors.Yellow
    sr1.RippleToColor = Colors.Red

    sr2.RippleDuration = 3000
    sr2.RippleShape = sr2.SHAPE_SQUARE
    sr2.EnableRandomColor = True
    sr2.EnableRandomPosition = True
    sr2.EnableColorTransition = True
    sr2.RippleStrokeWidth = 20
    sr2.EnableStrokeStyle = True
    sr2.RippleCount = 10
   
    sr3.RippleShape = sr3.SHAPE_CIRCLE
    sr3.EnableRandomColor = True
    sr3.EnableRandomPosition = False
    sr3.EnableColorTransition = True
    sr3.RippleStrokeWidth = 30
    sr3.EnableStrokeStyle = True
    sr3.RippleCount = 15
   
    sr3.RippleShape = sr3.SHAPE_CIRCLE
    sr3.EnableRandomColor = True
    sr3.EnableColorTransition = True
    sr3.EnableRandomPosition = False
    sr3.RippleStrokeWidth = 25
    sr3.EnableStrokeStyle = True
    sr3.RippleCount = 20
   
    sr4.RippleShape = sr4.SHAPE_SQUARE
    sr4.EnableRandomColor = True
    sr4.EnableColorTransition = True
    sr4.EnableRandomPosition = False
    sr4.RippleStrokeWidth = 20
    sr4.EnableStrokeStyle = True
    sr4.RippleCount = 15
   
    sr5.RippleShape = sr5.SHAPE_TRIANGLE
    sr5.EnableRandomColor = True
    sr5.EnableColorTransition = True
    sr5.EnableRandomPosition = False
    sr5.RippleStrokeWidth = 15
    sr5.EnableStrokeStyle = True
    sr5.RippleCount = 25
   
    sr6.RippleShape = sr6.SHAPE_TRIANGLE
    sr6.EnableRandomColor = True
    sr6.EnableColorTransition = True
    sr6.EnableRandomPosition = True
    sr6.RippleStrokeWidth = 10
    sr6.EnableStrokeStyle = True
    sr6.RippleCount = 30
    Dim lst As List
    lst.Initialize
    lst.Add(Colors.White)
    lst.Add(Colors.Gray)
    sr6.RippleRandomColors = lst
       
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Library:
ShapeRipple
Author:
Github: rodolfo navalon, Wrapped by: Johan Schoeman
Version: 1
  • ShapeRipple
    Fields:
    • SHAPE_CIRCLE As Int
    • SHAPE_SQUARE As Int
    • SHAPE_STAR As Int
    • SHAPE_TRIANGLE As Int
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • setRippleColor (rippleColor As Int, instant As Boolean)
      Change the base color of each ripple
      rippleColor: The ripple color
      instant: flag for when changing color is instant without delay
    • setRippleFromColor (rippleFromColor As Int, instant As Boolean)
      Change the starting color of the color transition
      rippleFromColor: The starting color
      instant: flag for when changing color is instant without delay
    • setRippleToColor (rippleToColor As Int, instant As Boolean)
      Change the end color of the color transition
      rippleToColor: The end color
      instant: flag for when changing color is instant without delay
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • EnableColorTransition As Boolean [write only]
      Enables the color transition for each ripple
    • EnableRandomColor As Boolean [write only]
      Enables the random coloring of each ripple
    • EnableRandomPosition As Boolean [write only]
      Enables the random positioning of ripples
    • EnableSingleRipple As Boolean [write only]
      Enables the single ripple rendering
    • EnableStrokeStyle As Boolean [write only]
      Enables the stroke style of each ripple
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Padding()() As Int
    • Parent As Object [read only]
    • RippleColor As Int [write only]
      Change the base color of each ripple
    • RippleCount As Int [write only]
      Change the number of ripples, default value is calculated based on the
      layout_width / ripple_width.
    • RippleDuration As Int [write only]
      Change the ripple duration of the animator
    • RippleFromColor As Int [write only]
      Change the starting color of the color transition
    • RippleMaximumRadius As Float [write only]
    • RippleRandomColors As List [write only]
      Change the developer predefined random colors
    • RippleShape As Int [write only]
      Change the shape renderer of the ripples
    • RippleStrokeWidth As Int [write only]
      Change the stroke width for each ripple
    • RippleToColor As Int [write only]
      Change the end color of the color transition
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int

1.png
 

Attachments

  • LibRes.zip
    879 bytes · Views: 228
  • b4aLibFiles.zip
    19.8 KB · Views: 214
  • b4aShapeRipple.zip
    8.2 KB · Views: 207
  • TheJavaCode.zip
    21.4 KB · Views: 201
Top