Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Toybox.Graphics;
- import Toybox.Lang;
- import Toybox.System;
- import Toybox.WatchUi;
- class watchimageView extends WatchUi.WatchFace {
- var myBmp;
- var font = WatchUi.loadResource(Rez.Fonts.customFont );
- function initialize() {
- WatchFace.initialize();
- myBmp = WatchUi.loadResource(Rez.Drawables.narutoWatch); //load the bitmap using your id in place of id_pic
- }
- // Load your resources here
- function onLayout(dc as Dc) as Void {
- setLayout(Rez.Layouts.WatchFace(dc));
- }
- // Called when this View is brought to the foreground. Restore
- // the state of this View and prepare it to be shown. This includes
- // loading resources into memory.
- function onShow() as Void {}
- // Update the view
- function onUpdate(dc as Dc) as Void {
- var x = 0,
- y = 0; //upper left is at 10,10
- dc.drawBitmap(x, y, myBmp);
- // Get and show the current time
- var clockTime = System.getClockTime();
- var timeString = Lang.format("$1$:$2$", [clockTime.hour, clockTime.min.format("%02d")]);
- dc.setColor(Graphics.COLOR_BLACK,Graphics.COLOR_TRANSPARENT);
- dc.drawText(dc.getWidth()/2,dc.getHeight()/2.06, font, timeString, Graphics.TEXT_JUSTIFY_CENTER|Graphics.TEXT_JUSTIFY_VCENTER);
- }
- // Called when this View is removed from the screen. Save the
- // state of this View here. This includes freeing resources from
- // memory.
- function onHide() as Void {}
- // The user has just looked at their watch. Timers and animations may be started here.
- function onExitSleep() as Void {}
- // Terminate any active timers and prepare for slow updates.
- function onEnterSleep() as Void {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement