Pebble.Ui
Retained virtual UI model for Pebble rendering.
`Pebble.Ui` provides a declarative scene graph for watch windows, layers, and drawing operations. Build values here and emit them through your app's render bridge to keep view logic in pure Elm.
mainWindow : WindowNode
mainWindow =
window 1
[ canvasLayer 2
[ fillRect
{ x = 0, y = 0, w = 144, h = 168 }
UiColor.black
]
]
Core nodes
Drawing operations
Resources, labels and path/context helpers
Drawing settings
Union Types
UiNode
type UiNodeRoot virtual UI node.
WindowNode
type WindowNodeA virtual window identified by a stable id.
LayerNode
type LayerNodeA virtual layer identified by a stable id.
RenderOp
type RenderOpDrawing operations for a canvas layer.
Label
type Labeltype Label
= WaitingForCompanionLocalized labels produced in Elm and rendered on watch.
Rotation
type RotationRotation value for Pebble graphics APIs.
Use `rotationFromPebbleAngle` when you already have Pebble angle units (`TRIG_MAX_ANGLE == 65536`) or `rotationFromDegrees` for degree inputs.
ContextSetting
type ContextSettingtype ContextSetting
= StrokeWidth Int
| Antialiased Int
| StrokeColor Int
| FillColor Int
| TextColor Int
| CompositingMode IntDrawing style settings used by `context`.
Type Aliases
Context
type alias Context = ( List ContextSetting, List RenderOp )Nested drawing context containing style settings and commands.
Bitmap
type alias Bitmap = UiResources.BitmapBitmap resource handle from `Pebble.Ui.Resources`.
Font
type alias Font = UiResources.FontFont resource handle from `Pebble.Ui.Resources`.
Path
type alias Path = ( List ( Int, Int ), ( Int, Int ), Int )Path geometry for path draw operations.
Point
type alias Point = { x : Int
, y : Int
}2D point for draw positions.
Rect
type alias Rect = { x : Int
, y : Int
, w : Int
, h : Int
}Rectangle bounds for draw operations.
Values
toUiNode
toUiNode : List RenderOp -> UiNodeBuild a complete single-window UI from drawing operations.
This is a convenience for watchfaces and apps whose view is just one canvas. It is equivalent to:
windowStack
[ window 1
[ canvasLayer 1 ops ]
]windowStack
windowStack : List WindowNode -> UiNodeBuild a window stack node.
window
window : Int -> List LayerNode -> WindowNodeBuild a window node with a stable id and layers.
canvasLayer
canvasLayer : Int -> List RenderOp -> LayerNodeBuild a canvas layer node with a stable id and draw operations.
text
text : Font -> Rect -> String -> RenderOpDraw a string in the given rectangle using a resource font.
textInt
textInt : Font -> Point -> Int -> RenderOpDraw an integer at the given position using a custom resource font.
textLabel
textLabel : Font -> Point -> Label -> RenderOpDraw a predefined label at the given position using a custom resource font.
clear
clear : UiColor.Color -> RenderOpClear the canvas to a color.
fillRect
fillRect : Rect -> UiColor.Color -> RenderOpFill a rectangle with a color.
pixel
pixel : Point -> UiColor.Color -> RenderOpDraw a single pixel with a color.
line
line : Point -> Point -> UiColor.Color -> RenderOpDraw a line with a color.
rect
rect : Rect -> UiColor.Color -> RenderOpDraw a rectangle outline with a color.
circle
circle : Point -> Int -> UiColor.Color -> RenderOpDraw a circle outline with a color.
fillCircle
fillCircle : Point -> Int -> UiColor.Color -> RenderOpDraw a filled circle with a color.
drawBitmapInRect
drawBitmapInRect : Bitmap -> Rect -> RenderOpDraw bitmap resource in the provided rectangle.
drawRotatedBitmap
drawRotatedBitmap : Bitmap -> Rect -> Rotation -> Point -> RenderOpDraw bitmap resource using width/height, angle and center point.
group
group : Context -> RenderOpGroup operations under a temporary style context.
pathFilled
pathFilled : Path -> RenderOpDraw a filled path.
pathOutline
pathOutline : Path -> RenderOpDraw a closed path outline.
pathOutlineOpen
pathOutlineOpen : Path -> RenderOpDraw an open path outline.
roundRect
roundRect : Rect -> Int -> UiColor.Color -> RenderOpDraw a rounded rectangle outline.
arc
arc : Rect -> Int -> Int -> RenderOpDraw an arc inside rectangle bounds in Pebble angle units.
fillRadial
fillRadial : Rect -> Int -> Int -> RenderOpDraw a filled radial slice inside rectangle bounds.
context
context : List ContextSetting -> List RenderOp -> ContextBuild a drawing context from settings and nested operations.
path
path : List Point -> Point -> Rotation -> PathBuild path data from points, offset and rotation.
rotationFromPebbleAngle
rotationFromPebbleAngle : Int -> RotationCreate a rotation from raw Pebble angle units (`0..65535`).
rotationFromDegrees
rotationFromDegrees : Float -> RotationCreate a rotation from degrees.
strokeWidth
strokeWidth : Int -> ContextSettingSet stroke width for a context.
antialiased
antialiased : Int -> ContextSettingEnable or disable antialiasing (`0` or `1`).
strokeColor
strokeColor : UiColor.Color -> ContextSettingSet stroke color for a context.
fillColor
fillColor : UiColor.Color -> ContextSettingSet fill color for a context.
textColor
textColor : UiColor.Color -> ContextSettingSet text color for a context.
compositingMode
compositingMode : Int -> ContextSettingSet graphics compositing mode (`0..4` Pebble `GCompOp`).