Back

addImage

JS Py
Hello World
Content:
- Examples
- Properties
- Methods

Adds an image into your layout.

img = ui.addImage( parent, file, options='Image', width?, height? ) → ui object: Image

Please note that a canvas image cannot switch to Button or Avatar in setOptions method.

Here are the available methods of the Image Component.

Examples

Example - Basic Image

class Main extends App
{
    onStart()
    {
        // Creates a fullscreen layout with objects vertically centered.
        this.main = ui.addLayout( "main", "Linear", "VCenter,FillXY")

        var image = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Hapus_Mango.jpg/220px-Hapus_Mango.jpg"

        // Add an image control to the main layout with a width of 7/10 of the parent width
        this.img = ui.addImage(this.main, image, "", 0.5)

        // Add callback handler for `onTouch` event on the image control
        this.img.setOnTouch( this.onTouch )
    }

    onTouch()
    {
        ui.showPopup( "You touched the mango!" )
    }
}
from hybrid import ui

def OnStart():
    main = ui.addLayout("main", "Linear", "VCenter,FillXY")

    image = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Hapus_Mango.jpg/220px-Hapus_Mango.jpg"

    img = ui.addImage(main, image, "", 0.5)

    img.setOnTouch(onTouch)

def onTouch(event):
    ui.showPopup("You touched the mango!")
Copy All       Run      

Example - Avatar

class Main extends App
{
    onStart()
    {
        // Creates a fullscreen layout with objects vertically centered.
        this.main = ui.addLayout( "main", "Linear", "VCenter,FillXY")

        var image = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Hapus_Mango.jpg/220px-Hapus_Mango.jpg"

        // Add an image control to the main layout.
        // Avatar option will ignore the width of the image control.
        this.img = ui.addImage(this.main, image, "Avatar")

        // Add callback handler for `onTouch` event on the image control
        this.img.setOnTouch( this.onTouch )
    }

    onTouch()
    {
        ui.showPopup( "You touched the mango!" )
    }
}
from hybrid import ui

def OnStart():
    main = ui.addLayout("main", "Linear", "VCenter,FillXY")

    image = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Hapus_Mango.jpg/220px-Hapus_Mango.jpg"

    img = ui.addImage(main, image, "Avatar")

    img.setOnTouch(onTouch)

def onTouch(event):
    ui.showPopup("You touched the mango!")
Copy All       Run      

Example - Button

class Main extends App
{
    onStart()
    {
        // Creates a fullscreen layout with objects vertically centered.
        this.main = ui.addLayout( "main", "Linear", "VCenter,FillXY")

        var image = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Hapus_Mango.jpg/220px-Hapus_Mango.jpg"

        // Add an image control to the main layout.
        // `Button` option will add touch effect when image is click.
        this.img = ui.addImage(this.main, image, "Button", 0.5)

        // Add callback handler for `onTouch` event on the image control
        this.img.setOnTouch( this.onTouch )
    }

    onTouch()
    {
        ui.showPopup( "You touched the mango!" )
    }
}
from hybrid import ui

def OnStart():
    main = ui.addLayout("main", "Linear", "VCenter,FillXY")

    image = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Hapus_Mango.jpg/220px-Hapus_Mango.jpg"

    img = ui.addImage(main, image, "Button", 0.5)

    img.setOnTouch(onTouch)

def onTouch(event):
    ui.showPopup("You touched the mango!")
Copy All       Run      

Example - Drawings

class Main extends App
{
    onStart()
    {
        // Creates a fullscreen layout with objects vertically centered.
        this.main = ui.addLayout( "main", "Linear", "VCenter", 1, 1 )

        // Add an image control into the main layout.
        // Pass canvas option to enable drawings on the image
        this.img = ui.addImage( this.main, "", "canvas", 1, 1 )
        this.img.lineCap = "round"
        this.img.lineJoin = "round"

        // Draw a line from (130, 40) to (300, 500)
        this.img.drawLine( 130, 40, 300, 500, "#009688", 10)

        // Draw a square from (320, 200) with a side of 200
        this.img.drawSquare( 320, 200, 200, "#683ab7")

        // Draw a circle centered at (400, 300) with a radius of 300
        this.img.drawCircle(400, 300, 250, "#00000000", "", 20)

        // Draw an arc centered at (800, 200) with a radius of 100
        // from 40 degrees to 270 degrees
        this.img.drawArc(800, 200, 100, 40, 270, "#44009688", "#009688", 10)

        // Draw a polyline from the given set of points below.
        var points = [
            [0,0],
            [400,40],
            [20, 40],
            [300, 340],
            [140, 500]
        ]
        this.img.lineCap = "square"
        this.img.lineJoin = "miter"
        this.img.drawPolyline( points, "blue", 10 )
    }
}
from hybrid import ui

def OnStart():
    main = ui.addLayout("main", "Linear", "VCenter", 1, 1)

    img = ui.addImage(main, "", "canvas", 1, 1)
    img.lineCap = "round"
    img.lineJoin = "round"

    img.drawLine(130, 40, 300, 500, "#009688", 10)

    img.drawSquare(320, 200, 200, "#683ab7")

    img.drawCircle(400, 300, 250, "#00000000", "", 20)

    img.drawArc(800, 200, 100, 40, 270, "#44009688", "#009688", 10)

    points = [
        [0, 0],
        [400, 40],
        [20, 40],
        [300, 340],
        [140, 500]
    ]
    img.lineCap = "square"
    img.lineJoin = "miter"
    img.drawPolyline(points, "blue", 10)
Copy All       Run      

Example - Text and Shapes

class Main extends App
{
    onStart()
    {
        // create a main layout with object vertically centered
        this.main = ui.addLayout( "main", "Linear", "VCenter", 1, 1 );

        // add a canvas image
        this.img = ui.addImage( this.main, "", "canvas", "300px", "500px");

        // draw rectangle
        this.img.drawRectangle(0, 0, 300, 500, "#fff", "", 4);

        // draw polygon
        this.img.drawPolygon([
            {x: 300, y: 0},
            {x: 300, y: 500},
            {x: 0, y: 500}
        ]);

        // draw text
        this.img.textSize = 100;
        this.img.textWeight = "bold";
        this.img.fillColor = "white";
        this.img.drawText("Hello", 30, 225, "", "", 3);
        this.img.drawText("World", 10, 325, "", "", 3);
    }
}
from hybrid import ui

def OnStart():
    main = ui.addLayout("main", "Linear", "VCenter", 1, 1)

    img = ui.addImage(main, "", "canvas", "300px", "500px")

    img.drawRectangle(0, 0, 300, 500, "#fff", "", 4)

    img.drawPolygon([
        {"x": 300, "y": 0},
        {"x": 300, "y": 500},
        {"x": 0, "y": 500}
    ])

    img.textSize = 100
    img.textWeight = "bold"
    img.fillColor = "white"
    img.drawText("Hello", 30, 225, "", "", 3)
    img.drawText("World", 10, 325, "", "", 3)
Copy All       Run      

Example - Analog Clock

class Main extends App
{
    onStart()
    {
        // Create a linear layout with objects vertically centered.
        this.main = ui.addLayout( "main", "Linear", "", 1, 1 )

        ui.addAppBar( this.main, "Analog Clock" )

        // Create a canvas image
        this.img = ui.addImage( this.main, "", "canvas", "300px", "300px")
        this.img.margins = [null, 0.1]

        // Set the initial line styles
        this.img.lineCap = "round"
        this.img.lineWidth = 4
        this.img.strokeColor = "#009688"
        this.img.lineJoin = "round"

        // Create a text to display the time
        this.time = ui.addText(this.main, "00:00:00", "h6,bold")
        this.time.setMargins(0, 0.05, 0, 0)

        // Call the draw function every second
        setInterval( this.draw.bind(this), 1000)
    }

    draw()
    {
        // Clear all the drawings first in the canvas
        this.img.clear()

        let x, y, n

        // Draw the 12 dot for every hour
        for( n=1; n<=12; n++ ) {
            x = 130 * Math.cos( n * (Math.PI/6) )
            y = 130 * Math.sin( n * (Math.PI/6) )

            x += 150
            y += 150

            this.img.drawCircle(x, y, 4, "#311b92")
        }

        var date = new Date()

        // Get the hour, minutes and seconds
        var hour = date.getHours() > 12 ? date.getHours()-12 : date.getHours();
        var minutes = date.getMinutes()
        var seconds = date.getSeconds()

        // Calculate the corresponding angles
        var hourAngle = hour * ( Math.PI / 6) - ( Math.PI/2 )
        var minAngle = minutes * ( Math.PI / 30 ) - ( Math.PI/2 )
        var secAngle = seconds * ( Math.PI / 30 ) - ( Math.PI/2 )

        // Draw each hand by calling the drawHand function
        this.drawHand(hourAngle, 80, 7, "#311b92")
        this.drawHand(minAngle, 100, 4, "#1e88e5")
        this.drawHand(secAngle, 110, 2, "#d81b60")

        // Draw the black cirlce in the center
        this.img.drawCircle(150, 150, 8, "#000")

        // Display the time
        this.time.text = (`${hour}`.padStart(2, '0')) + ":"+
            (`${minutes}`.padStart(2, '0'))+":" +
            (`${seconds}`.padStart(2, '0')) + (date.getHours() > 12 ? " PM" : " AM")
    }

    drawHand( angle, length, width, color )
    {
        var x, y

        x = length * Math.cos( angle )
        y = length * Math.sin( angle )

        x += 150
        y += 150

        // Draw the hand
        this.img.drawLine(150, 150, x, y, color, width )
    }
}
from hybrid import ui
import math

def OnStart():
    global img, time
    main = ui.addLayout("main", "Linear", "VCenter", 1, 1)

    ui.addAppBar(main, "Analog Clock")

    img = ui.addImage(main, "", "canvas", "300px", "300px")

    img.lineCap = "round"
    img.lineWidth = 4
    img.strokeColor = "#009688"
    img.lineJoin = "round"

    time = ui.addText(main, "00:00:00", "h6,bold")
    time.setMargins(0, 0.05, 0, 0)

    draw()
    app.SetInterval(draw.bind(), 1000)

def draw():
    img.clear()

    x, y, n = 0, 0, 0

    for n in range(1, 13):
        x = 130 * math.cos(n * (math.pi / 6))
        y = 130 * math.sin(n * (math.pi / 6))

        x += 150
        y += 150

        img.drawCircle(x, y, 4, "#311b92")

    date = datetime.datetime.now()

    hour = date.hour if date.hour <= 12 else date.hour - 12
    minutes = date.minute
    seconds = date.second

    hourAngle = hour * (math.pi / 6) - (math.pi / 2)
    minAngle = minutes * (math.pi / 30) - (math.pi / 2)
    secAngle = seconds * (math.pi / 30) - (math.pi / 2)

    drawHand(hourAngle, 80, 7, "#311b92")
    drawHand(minAngle, 100, 4, "#1e88e5")
    drawHand(secAngle, 110, 2, "#d81b60")

    img.drawCircle(150, 150, 8, "#000")

    time.text = (
        str(hour).zfill(2) + ":" +
        str(minutes).zfill(2) + ":" +
        str(seconds).zfill(2) +
        " " +
        ("PM" if date.hour > 12 else "AM")
    )

def drawHand(angle, length, width, color):
    x = length * math.cos(angle)
    y = length * math.sin(angle)

    x += 150
    y += 150

    img.drawLine(150, 150, x, y, color, width)
Copy All       Run      

Example - Scratch Pad

class Main extends App
{
    onStart()
    {
        this.color = "#000000"
        this.main = ui.addLayout( "main", "Linear", "Top", 1, 1 );
        this.main.setChildMargins(0, 0.01, 0, 0.01);

        ui.addText(this.main, "Color", "H5");

        ui.addDivider(this.main);

        var lay = ui.addLayout( this.main, "Linear", "Horizontal,Center,VCenter", 1)
        lay.childSpacing = "even"

        var colors = ["#009688", "#673ab7", "#e53935", "#1e88e5"]

        for( var i=0; i<colors.length; i++ ) {
            var btn = ui.addLayout( lay, "Linear", "", "48px", "48px" )
            btn.backColor = colors[i];
            btn.setCornerRadius(8,8,8,8);
            btn.setOnTouch( this.changeColor.bind(this, colors[i]) );
        }

        ui.addDivider(this.main);

        ui.addText( this.main, "Thickness", "H5")
        this.sld = ui.addSlider( this.main, 5, "", 0.9)
        this.sld.setRange(5, 25);
        this.sld.value = 15;

        this.img = ui.addImage( this.main, "", "canvas", 0.96, 0.7);
        this.img.fill = "#e0e0e0";
        this.img.setOnTouchMove( this.draw );
        this.img.setOnTouchDown( this.draw );
        this.img.setOnTouch( this.draw );
    }

    changeColor( color ) { this.color = color; }

    draw( e ) {
        this.img.drawCircle( e.x, e.y, this.sld.value, this.color, "", 0 )
    }
}
from hybrid import ui

def OnStart():
    color = "#000000"
    main = ui.addLayout("main", "Linear", "Top", 1, 1)
    main.setChildMargins(0, 0.01, 0, 0.01)

    lay = ui.addLayout(main, "Linear", "Horizontal,Center,VCenter", 1)
    lay.setChildMargins(0.01, 0, 0.01, 0)

    colors = ["#009688", "#673ab7", "#e53935", "#1e88e5"]

    ui.addText(lay, "Color", "H5")
    for color in colors:
        btn = ui.addButton(lay, "", color)
        btn.onClick = changeColor

def changeColor():
    color = sender.backgroundColor
Copy All       Run      

Properties

The following properties are available on the Image object:

absHeightNumber
absLeftNumber
absTopNumber
absWidthNumber
backColorString
backImageString
borderNumber
borderColorString
borderStyleString
cornerRadiusNumber
disabledBoolean
elObject
elStyleString
errorIconString
fillString
fillColorString
fontFileString
heightNumber
imageString
isVisibleBoolean
leftNumber
lineCapString
lineJoinString
lineWidthNumber
marginsList
miterLimitNumber
opacityNumber
optionsString
paddingList
parentObject
pixelDataList
positionObject
rotationNumber
strokeColorString
textColorString
textSizeNumber
textStyleString
topNumber
typeString
visibilityString
widthNumber

Methods

The following methods are available on the Image object:

clear()
getPixelColor( x, y, format ) → List
getPixelData( x, y, width, height ) → Object
getPosition( options ) → Object
gone()
hide()
measureText( text ) → Object
rotate( angle, x, y )
setScale( x, y )
show()
Boolean: Value. Can be `true` `false`
Number: Fraction of the parent width `[0-1]`.
Number: Fraction of the parent height `[0-1]`.
Number: The time in milliseconds.
Number: The z-index. A negative value behaves like `sendBackward` method.
Number: The x-coordinate of the center of the arc in pixels.
Number: The y-coordinate of the center of the arc in pixels.
Number: The radius of the arc in pixels.
Number: The starting angle in degress
Number: The angle in degress in which the arc will stop.
Number: The stroke thickness.
Number: The x-coordinate of the center of the circle in pixels.
Number: The y-coordinate of the center of the circle in pixels.
Number: The radius of the circle in pixels.
Number: The stoke thickness.
Number: The distance from the left of the top-left corner of the image in pixels.
Number: The distance from the top of the top-left corner of the image in pixels.
Number: If provided,  the image will be shrink or stretch to fill this width in pixels.
Number: If provided,  the height of the image will be shrink or stretch to fill this height in pixels.
Number: The x-coordinate of the starting point in pixels.
Number: The y-coordinate of the starting point in pixels
Number: The x-coordinate of the second point in pixels.
Number: The y-coordinate of the second point in pixels.
Number: The x-coordinate in pixels.
Number: The y-coordinate in pixels.
Number: The width of point in pixels.
Number: The distance from the left of the top-left corner of the rectangle in pixels.
Number: The distance from the top of the top-left corner of the rectangle in pixels.
Number: The width of the rectangle in pixels.
Number: The height of the rectangle in pixels.
Number: The position from the left of the top-left corner of the square in pixels.
Number: The distance from the top of the top-left corner of the square in pixels.
Number: The width of the square in pixels.
Number: The stroke thickness in pixels.
Number: Distance from the left in pixels.
Number: Distance from the top in pixels.
Number: The border width in pixels.
Number: The x-coordinate of the pixel from the left.
Number: The y-coordinate of the pixel from the top.
Number: The x-coordinate where to start getting image data.
Number: The y-coordinate where to start getting image data.
Number: The width of the image data.
Number: The height of the image data.
Number: The angle of rotation in degrees.
Number: An optional x-coordinate of the pivot.
Number: An optional y-coordinate of the pivot.
Number: The z-index. A positve value behaves like `bringForward` method.
Number: Border-left thickness in pixels.
Number: Border-top thickness in pixels.
Number: Border-right thickness in pixels.
Number: Border-bottom thickness in pixels.
Number: Top-Left border radius.
Number: Top-Right border radius.
Number: Bottom-Right border radius.
Number: Bottom-Left border radius.
Number: The text-size for the text.
Number: Left margin. You can also pass string e.g. `12rem`
Number: Top margin. You can also pass string e.g. `12rem`
Number: Right margin. You can also pass string e.g. `12rem`
Number: Bottom margin. You can also pass string e.g. `12rem`
Number: Fraction of the component width.
Number: Fraction of the component height. [0-1]
Number: Fraction of the component width. [0-1]
Number: The x-coordinate of the pixel.
Number: The y-coordinate of the pixel.
Number: The x-coordinate of the top-left corner.
Number: The y-coordinate of the top-left corner.
Number: The width of the new image data.
Number: The height of the new image data.
Number: Fraction of the parent width. [0-1]
Number: Fraction of the parent height. [0-1]
Number: The x-scale of the component.Values less than `0` is smaller than the normal. While values greater than `1` is greater than the normal.
Number: The y-scale of the component. Values less than `1` is smaller than the normal. While vaues greater than `1` is greater than the normal.
Number: The new x-coordinate of the origin.
Number: The new y-coordinate of the origin.
String: “The path to the image.”
String: “A comma seprated options.
`Image`”
, “ `Canvas`”, “ `Button` and `Avatar`. Default is image.
For `Avatar` you can pass `Small` or `Large`.”
String: “The type of animation. Here are the available values
`bounce`”
, “ `flash`”, “ `pulse`”, “ `rubberBand`”, “ `shakeX`”, “ `shakeY`”, “ `headShake`”, “ `swing`”, “ `tada`”, “ `wobble`”, “ `jello`”, “ `heartBeat`”,
Back Entrances: `backInDown`”
, “ `backInLeft`”, “ `backInRight`”, “ `backInUp`
Back Exits: `backOutDown`”
, “ `backOutLeft`”, “ `backOutRight`”, “ `backOutUp`
Bouncing Entrances: `bounceIn`”
, “ `bounceInDown`”, “ `bounceInLeft`”, “ `bounceInRight`”, “ `bounceInUp`
Bouncing exits: `bounceOut`”
, “ `bounceOutDown`”, “ `bounceOutLeft`”, “ `bounceOutRight`”, “ `bounceOutUp`
Fading entrances: `fadeIn`”
, “ `fadeInDown`”, “ `fadeInDownBig`”, “ `fadeInLeft`”, “ `fadeInLeftBig`”, “ `fadeInRight`”, “ `fadeInRightBig`”, “ `fadeInUp`”, “ `fadeInUpBig`”, “ `fadeInTopLeft`”, “ `fadeInTopRight`”, “ `fadeInBottomLeft`”, “ `fadeInBottomRight`
Fading exits: `fadeOut`”
, “ `fadeOutDown`”, “ `fadeOutDownBig`”, “ `fadeOutLeft`”, “ `fadeOutLeftBig`”, “ `fadeOutRight`”, “ `fadeOutRightBig`”, “ `fadeOutUp`”, “ `fadeOutUpBig`”, “ `fadeOutTopLeft`”, “ `fadeOutTopRight`”, “ `fadeOutBottomRight`”, “ `fadeOutBottomLeft`
Flippers: `flip`”
, “ `flipInX`”, “ `flipInY`”, “ `flipOutX`”, “ `flipOutY`
Lightspeed: `lightSpeedInRight`”
, “ `lightSpeedInLeft`”, “ `lightSpeedOutRight`”, “ `lightSpeedOutLeft`
Rotating Entrances: `rotateIn`”
, “ `rotateInDownLeft`”, “ `rotateInDownRight`”, “ `rotateInUpLeft`”, “ `rotateInUpRight`
Rotating Exits: `rotateOut`”
, “ `rotateOutDownLeft`”, “ `rotateOutDownRight`”, “ `rotateOutUpLeft`”, “ `rotateOutUpRight`
Specials: `hinge`”
, “ `jackInTheBox`”, “ `rollIn`”, “ `rollOut`
Zooming Entrances: `zoomIn`”
, “ `zoomInDown`”, “ `zoomInLeft`”, “ `zoomInRight`”, “ `zoomInUp`
Zooming Exits: `zoomOut`”
, “ `zoomOutDown`”, “ `zoomOutLeft`”, “ `zoomOutRight`”, “ `zoomOutUp`
Sliding Entrances: `slideInDown`”
, “ `slideInLeft`”, “ `slideInRight`”, “ `slideInUp`
Sliding Exits: `slideOutDown`”
, “ `slideOutLeft`”, “ `slideOutRight`”, “ `slideOutUp`”
String: “A hexadecimal color.”
String: “The type of arc. Can be `filled` or `segment`.”
String: “Path to image file.”
String: “The text to be drawn.”
String: “Text color in hexadecimal format `#rrggbb`.”
String: “Text border color in hexadecimal format `#rrggbb`.”
String: “Pass `"hex"` to return color as hexadecimal formart `"#rrggbb"` or `"hexa"` to include include alpha `"#aarrggbb"` . Pass `"rgb"` to return color as `rgb` format `"rgb(r”, “ g”, “ b)"` or pass `"rgba"` for `"rgba(r”, “ g”, “ b”, “ a)"`.”
String: “The mode of the measurements. Values can be `px` or `%`”
String: “The text to measure.”
String: “Border color in hexadecimal format `#rrggbb`.”
String: “Border-styles. Values can be `dotted`”, “ `dashed`”, “ `solid`”, “ `double`”, “ `groove`”, “ `ridge`”, “ `inset` and `outset`. Default is `solid`”
String: “Unit of measurement. Values are `px` `rem` or `%`.”
String: “The font-family for the text.”
String: “Value can be `normal` or `italic`”, “”
String: “Values can be `normal` or `bold`.”
String: “Unit of measurement.
`rem` for root em.
`px` for pixels
`%` relative to its parent dimension.
`v` relative to viewport dimension.”
String: “Unit of measurement.
`rem` for root em.
`px` for pixels
`%` relative to its parent dimensions
`v` relative to viewport dimensions.”
String: “A hexadecimal color format of the form `"#rrggbb"` or a comma separated rgb color of the form `"r”, “g”, “b"`.”
String: “Base64 encoded string of the image or the `ImageData` object of the canvas.”
String: “Unit of measurment. Can be "px"”, “ "rem"”, “ "%"”, “ "v" for viewport width/height or any css supported unit.”
Object: The parent layout where to add the image.
Object: The pointer event object.
Object: The position of the touch event.
List: An array of coordinates. Each element on this array if an array of the form `[x, y]` where `x` is the x-coordinate of a point and `y` is the y-coordinate of a point, or an object of the form `{x, y}`.
List: An array of coordinates. Each element on this array is an array of the form `[x, y]` where `x` is the x-coordinate of a point and `y` is the y-coordinate of a point, or an object of the form `{x, y}`.
function( event )
function()
function( pos )
img.absHeight
Returns the absolute height of the control in pixels.
img.absLeft
Returns the absolute distance of the control from the left in pixels.
img.absTop
Returns the absolute distance of the control from the top in pixels.
img.absWidth
Returns the absolute width of the control in pixels.
img.animate
Animate the component.
img.backColor
A hexadecimal color of the form #rrggbb
img.backImage
The path to your image file.
img.border
Sets or returns the border thickness in pixels.
img.borderColor
Sets or returns the border color. Color is in hexadecimal form #rrggbb
img.borderStyle
Sets or returns the border style. Values can be dotted, dashed, solid, double, groove, ridge, inset and outset. Default is solid.
img.bringForward
Bring this component forward by a given z-index.
img.clear
Clears the drawings by filling the whole canvas with white background color.
img.cornerRadius
Sets or returns the corner radius in pixels.
img.destroy
Destroy the component.
img.disabled
Sets or returns the disabled state of the control.
img.drawArc
Draws an arc in the canvas.
img.drawCircle
Draws a circle in the canvas.
img.drawImage
Draws an image to the canvas.
img.drawLine
Draws a line between two points in the canvas.
img.drawPoint
Draws a single pixel point in a specified coordinate.
img.drawPolygon
Draws a polygon on the canvas by passing an array of points.
img.drawPolyline
Draws a polyline on the canvas by passing an array of points.
img.drawRectangle
Draws a rectangle into the canvas.
img.drawSquare
Draws a square into the canvas.
img.drawText
Add a text in the canvas image.
img.el
Returns the html container element for the control.
img.elStyle
Sets the style of the html container element.
img.enableContextMenu
Enable or disbale the context menu or the right click menus.
img.errorIcon
Sets or returns the material icon for error placeholder image.
img.fill
Sets or returns the background color of the canvas.
img.fillColor
Sets or returns the fill color used on close paths such as square, circle, rectangle or arcs.
img.fontFile
Sets or returns the relative path to the font-family use.
img.getPixelColor
Get the color of a single pixel in the image. The returned array is of the form [red, green, blue, alpha].
img.getPixelData
Returns the pixel data of the image.
img.getPosition
Returns the position of the component. The return object is of the form {left, top, right, bottom}
img.gone
Destroy the component.
img.height
Sets or returns the height of the control as a fraction of the parent control.
img.hide
Hide the component.
img.image
Sets or returns the path or url of the image file.
img.isVisible
Returns whether the control is visible or not.
img.left
Returns the distance of the control from the left.
img.lineCap
Sets or returns the style of the end caps for a line. Values can be square round butt
img.lineJoin
Sets or returns the type of corner created when two lines meet. Values bevel round miter
img.lineWidth
Sets or returns the current line thickness.
img.margins
Sets or returns the margin of the control. Works on controls with Linear parent only. You can also pass a number to set equal margins for all sides.
img.measureText
Measure the text metrics with the current settings of the canvas context.
img.miterLimit
Sets or returns the maximum miter length.
img.opacity
Sets or returns the opacity of the control.
img.options
Sets or returns the options of the control.
img.padding
Sets or returns the padding of the control. You can also pass a number to set equal padding for all sides.
img.parent
Returns the parent layout control.
img.pixelData
Returns the pixel data of the image.
img.position
Returns the position of the control. The returned object has left top right and bottom props.
img.rotate
Rotate the canvas at a given angle and pivot point.
img.rotation
Sets or returns the angle of rotation in degrees.
img.sendBackward
Bring this component backward by a given z-index.
img.setBorder
Sets the border line for the component container.
img.setCornerRadius
Sets the corner radius of the component.
img.setFont
Sets a single line font styling for rendering text on canvas.
img.setMargins
Sets the margin of the component.
img.setOnContextMenu
Adds a callback function on right click.
img.setOnLoad
Sets a callback function on load event.
img.setOnLongTouch
Adds a callback handler for a long touch event. The touch timer is about 500 milliseconds.
img.setOnTouch
Sets a callback function when the image component is touch.
img.setOnTouchDown
Add a callback function on touch down event.
img.setOnTouchMove
Sets a callback function when the a mouse move event is triggered.
img.setOnTouchUp
Add a callback function on touch up event.
img.setPadding
Sets the padding of the component's container.
img.setPixelColor
Sets the color of a specific pixel in the canvas.
img.setPixelData
Set the pixel data of the canvas.
img.setPosition
Sets the position of the component relative to its parent dimensions.
img.setScale
Sets the x and y scaling of the component. This will ignore the positioning and flow of controls in the layout.
img.setSize
Sets the size of the component.
img.show
Show the component.
img.strokeColor
Sets or returns the current color of the line or stroke.
img.textColor
Sets or returns the color of the text.
img.textSize
Sets or returns the size of the text within the control.
img.textStyle
Sets or returns the text-style for drawing in the canvas. Values are normal and italic.
img.top
Returns the distance of the control from the top.
img.translateOrigin
Translate the origin of the canvas at a new coordinate with the given angle of rotation.
img.type
Returns the type of the control.
img.visibility
Sets or returns the visibility of the control.
img.width
Sets or returns the width of the control as a fraction of the parent control.