Back

CreateImage

Returns a Image object.

For more information in the detailed docs see CreateImage

  img = app.CreateImage( file, width, height, options, w, h ) → app object - Image

Example - Original Size



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    img = app.CreateImage( "/Sys/Img/Droid1.png" );
    img.SetOnTouch( img_OnTouch );
    lay.AddChild( img );

    app.AddLayout( lay );
}

function img_OnTouch( ev )
{
    if( ev.action=="Down" )
        app.ShowPopup( "Ouch!" );
}
    Copy     Copy All       Run      

Example - Stretched



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    img = app.CreateImage( "/Sys/Img/Droid1.png", 0.5, 0.7 );
    img.SetOnTouch( img_OnTouch );
    lay.AddChild( img );

    app.AddLayout( lay );
}

function img_OnTouch( ev )
{
    if( ev.action=="Down" )
        app.ShowPopup( "Aaaargh!" );
}
    Copy     Copy All       Run      

Example - Maintain Aspect



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    img = app.CreateImage( "/Sys/Img/Droid1.png", 0.5, -1 );
    img.SetOnTouch( img_OnTouch );
    lay.AddChild( img );

    app.AddLayout( lay );
}

function img_OnTouch( ev )
{
    if( ev.action=="Down" )
        app.ShowPopup( ev.x[0] + ", " + ev.y[0], "Short" );
}
    Copy     Copy All       Run      

Example - Images



<sample Draw Shapes>
function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    img = app.CreateImage( null, 0.8, 0.8 );
    lay.AddChild( img );

    img.SetColor( "#8888ff" );
    img.SetPaintColor( "#ff0000" );
    img.DrawCircle( 0.5, 0.5, 0.1 );
    img.DrawRectangle( 0.7, 0.7, 0.05 );

    app.AddLayout( lay );
}
    Copy     Copy All       Run      

The following methods are available on the Image object:

  Clear()
  Draw( func, p1, p2, p3, p4, p5, p6, p7 )
  DrawArc( x1, y1, x2, y2, start, sweep )
  DrawCircle( x, y, radius )
  DrawFrame( ms )
  DrawImage( image, x, y, w, h, angle, mode )
  DrawLine( x1, y1, x2, y2 )
  DrawPoint( x, y )
  DrawRectangle( x1, y1, x2, y2 )
  DrawText( txt, x, y )
  Flatten()
  Focus()
  GetAbsHeight() → number: integer
  GetHeight( options ) → number
  GetLeft( options ) → number
  GetName() → string: "name"
  GetParent()
  GetPixelColor( x, y ) → list: [red,green,blue]
  GetPixelData( format, left, top, width, height ) → string: "data"
  GetPosition( options ) → object: { left, top, right, bottom}
  GetTop( options ) → number
  GetType() → string: "Image"
  GetVisibility() → string: "Show" or "Hide" or "Gone"
  Gone()
  IsEnabled() → boolean
  IsOverlap( obj, depth ) → boolean
  IsVisible() → boolean
  Method( name, types, p1, p2, p3, p4 )
  Move( x, y )
  Reset()
  Scale( x, y )
  SetName( name )
  SetScale( x, y )
  Show()
  Skew( x, y )
  Update()

string: path to file or folder ( "/absolute/..." or "relative/..." )
number: fraction of screen width
number: fraction of screen height
string: "fix" or "alias" or "ScaleCenter" or "async" or "FontAwesome" or "Resize"
number: pixel
number: -180..180
number: -100..100
number: 100..100
number: 0..100
Adjust the visual color effect of the control by setting the Hue (by angle in degrees in a color circle), the saturation, brightness and contrast of the control.
clear wimage contrastent
Removes the focus of the control so that the user no longer has immediate access to it.
unknown
?
number
number: angle in degrees ( 0 - 360 )
DrawArc
DrawCircle
DrawFrame
app object: app image
DrawImage
list
draw image using format matrix (list[9])
DrawLine
draw single pixel
DrawRectangle
list: [data]
draws a graph in relation to the range
string
DrawText
?
Set the focus to the control so that the user can interact with it immediately.
Get the absolute height of the control in pixels.
string: "" or "px"
Get the height of the control as screen height relative float or in pixels with the px option.
string: "" or "px"
Get the distance from the control to the left parent border as width relative float or in pixels with the px option.
return name set via SetName
Returns the parent control object where the object was added to - commonly a layout.
number: integer
[r,g,b] values between 0 and 255
string: "rawbase64" or "pngbase64" or "jpgbase64"
string: "screen", "px"
Returns data about the position and size of the control.
If the screen option is given the position on the screen will be returned. Otherwise relative to the parent control.
The px options turns the relative values into pixels.
string: "" or "px"
Get the distance from the control to the upper parent border as height relative float or in pixels with the px option.
Returns the control class name.
Returns the current visibility state of the control. The Values are:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
Hides the control without consuming any more layout space as if it were never there.
Returns whether the control is currently useable by the user.
app object
Returns whether the control overlaps with another by a given distance.
Returns whether the control is currently visible to the user, ignoring overlaying controls.
MeasureText
string: comma separated: "boolean", "char", "byte", "short", "int", "long", "float", "double"
Allows access to other functions defined on the object in Java via reflection.
?
?
rotate image contrastent
number: factor
scale image contrastent
alpha value between 0 and 255
boolean
en/disable updating image after drawing
number: 0..0.99 or 1..256
Set the transparency of the background by an alpha value between 0 (no transparency) and 0.99 (full transparent) or 1 (no transparency) and 256 (full transparent)
string:
  hexadecimal: "#rrggbb", "#aarrggbb"
  colourName: "red", "green", ...
Changes the background color of the control.
string: "left-right" or "right-left" or "top-bottom" or "bottom-top"
Define the background color of the control with a gradient. The default gradient direction is from top to bottom, but you can change it from left to right and the reversed versions of course.
Define a radial color gradient for the background of control.
string: "repeat"
Changes the background to an image which can be repeated using the repeat option.
An image which is often used with that option is '/res/drawable/pattern_carbon' - try it out!
Fill the image with a specific color.
string: "Add" or "Multiply" or "clear" or "darken" or "lighten" or "overlay" or "screen" or "xor" or "src_in" or "src_out" or "src_atop" or "src_over" or "dst_in" or "dst_out" or "dst_atop" or "dst_over"
Adjust the visual color effect with a colour and a given BlendMode. More information about BlendMode can be foind in the Android Developer page.
En/Disable the control physically and visually so that the user can/can not access the control. Events like OnTouch will still be fired.
Change the font style by defining a font file.
string: path to file or folder ( "/absolute/..." or "relative/..." )
app object: app image
set image from file or other image object
string: "" or "px" or "sp" or "dip" or "mm" or "pt"
Define a distance to other controls on each side of the control.
number: milliseconds
delay between two OnTouch events
change name
function()
?
function(self)
callen when object long pressed
function(event)
Define a callback function that is called when the user touches the control. In addition, an event object is passed to the callback function to obtain information about the touch type, the touch position(s), the amount of touches and the control that was touched.
function(event)
called when finger comes down
function(event)
called when finger was moved over screen
function(event)
called when finger leaves screen
string: "" or "px" or "sp" or "dip" or "mm" or "pt"
Define distances that elements within the control are to maintain from the control borders.
SetPaintColor
string: "fill" or "line" or "?"
SetPaintStyle
SetPixelData
SetPixelMode
string: "" or "px"
Defines the position and size for the control if the parent is an absolute layout.
Scales the control along with its contents by the factors passed to the function.
string: "" or "spx"
Change the size of the control in either screen relative values or in pixels if the px option was given.
SetTextSize
En/Disables touch events to be fired on the control. Other events like OnChange will still be fired.
string: "Show" or "Hide" or "Gone"
Change the visibility of the control to one of the available modes:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
Set the visibility of the control to "Show".
?
?
object: {x, y, sw, sh, rot}
string: "Linear.None" or "Quadratic.In/Out" or "Cubic.In/Out" or "Quartic.In/Out" or "Quintic.In/Out" or "Sinusoidal.In/Out" or "Exponential.In/Out" or "Circular.In/Out" or "Elastic.In/Out" or "Back.In/Out" or "Bounce.In/Out"
function()
Performs an animation on the control.
The target object is for the position, size and rotation that the control has at the end of the animation.

The type specifies the behavior and the speed of the animation. Separated by a dot, you must also specify whether you want to apply this behavior to the beginning (In), end (Out), or to both (InOut) times of the animation.

With the amount of repeats you can control how many times you want to play the animation.

If you have jojo activated, the animation will alternate between forward and backward playback, so that if the repetition value is odd, the control will be at the start position again at the end of the animation.

Finally the callback function will be called after the animation has finished. Well, it's about time!
neccessary when using SetAutoUpdate(false)