Class: Toybox::WatchUi::Drawable

Inherits:
Lang::Object show all

Overview

Drawable is the base class of a drawable object.

A Drawable can be constructed using the resource compiler and loaded through the resource (Rez) module.

Examples:

Using a Drawable defined as a resource

// The drawable.xml file contents:
// <drawable-list id="shapes" background="Gfx.COLOR_TRANSPARENT">
//     <shape type="circle" x="78" y="160" radius="8" color="Gfx.COLOR_RED" />
//     <shape type="rectangle" x="51" y="137" width="76" height="20" color="Gfx.COLOR_BLUE" />
// </drawable-list>

using Toybox.Graphics;
using Toybox.WatchUi;

class MyDrawableView extends WatchUi.View {
    var myShapes;

    function initialize() {
        View.initialize();
        myShapes = new Rez.Drawables.shapes();
    }

    function onUpdate(dc) {
        dc.setColor(
            Graphics.COLOR_WHITE,
            Graphics.COLOR_BLACK
        );
        dc.fillRectangle(
            0,
            0,
            dc.getWidth(),
            dc.getHeight()
        );
        myShapes.draw(dc);
    }
}

Since:

  • 1.0.0

Direct Known Subclasses

Bitmap, Selectable, Text, TextArea

Direct Known Subclasses

Bitmap, Selectable, Text, TextArea

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(settings) ⇒ Drawable

Returns a new instance of Drawable

Parameters:

Options Hash (settings):

Since:

  • 1.0.0


15538
15539
# File 'Monkeybrains.rb', line 15538

def initialize(settings)
end

Instance Attribute Details

heightToybox::Lang::Number

The clip height of the Drawable object.

Returns:

Since:

  • 1.0.0


15523
15524
15525
# File 'Monkeybrains.rb', line 15523

def height
  @height
end

identifierToybox::Lang::String

The ID used to identify the Drawable object.

Returns:

Since:

  • 1.0.0


15503
15504
15505
# File 'Monkeybrains.rb', line 15503

def identifier
  @identifier
end

locXToybox::Lang::Number

The absolute, on-screen x-coordinate of the Drawable object.

Returns:

Since:

  • 1.0.0


15508
15509
15510
# File 'Monkeybrains.rb', line 15508

def locX
  @locX
end

locYToybox::Lang::Number

The absolute, on-screen y-coordinate of the Drawable object.

Returns:

Since:

  • 1.0.0


15513
15514
15515
# File 'Monkeybrains.rb', line 15513

def locY
  @locY
end

widthToybox::Lang::Number

The clip width of the Drawable object.

Returns:

Since:

  • 1.0.0


15518
15519
15520
# File 'Monkeybrains.rb', line 15518

def width
  @width
end

Instance Method Details

draw(dc) ⇒ Object

Draw an object to the device context (Dc).

This method assumes that the device context has already been configured to the proper settings.

Parameters:

Since:

  • 1.0.0


15547
15548
# File 'Monkeybrains.rb', line 15547

def draw(dc)
end

setLocation(x, y) ⇒ Object

Set the on-screen location for a Drawable object.

Parameters:

Since:

  • 1.0.0


15554
15555
# File 'Monkeybrains.rb', line 15554

def setLocation(x, y)
end

setSize(w, h) ⇒ Object

Set the size of a Drawable object.

Parameters:

Since:

  • 1.0.0


15561
15562
# File 'Monkeybrains.rb', line 15561

def setSize(w, h)
end