Advertisement
Guest User

Untitled

a guest
Sep 12th, 2021
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. import Toybox.Graphics;
  2. import Toybox.Lang;
  3. import Toybox.System;
  4. import Toybox.WatchUi;
  5.  
  6.  
  7. class watchimageView extends WatchUi.WatchFace {
  8. var myBmp;
  9. var font = WatchUi.loadResource(Rez.Fonts.customFont );
  10. function initialize() {
  11. WatchFace.initialize();
  12. myBmp = WatchUi.loadResource(Rez.Drawables.narutoWatch); //load the bitmap using your id in place of id_pic
  13. }
  14.  
  15. // Load your resources here
  16. function onLayout(dc as Dc) as Void {
  17. setLayout(Rez.Layouts.WatchFace(dc));
  18. }
  19. // Called when this View is brought to the foreground. Restore
  20. // the state of this View and prepare it to be shown. This includes
  21. // loading resources into memory.
  22. function onShow() as Void {}
  23.  
  24. // Update the view
  25. function onUpdate(dc as Dc) as Void {
  26. var x = 0,
  27. y = 0; //upper left is at 10,10
  28. dc.drawBitmap(x, y, myBmp);
  29.  
  30. // Get and show the current time
  31. var clockTime = System.getClockTime();
  32. var timeString = Lang.format("$1$:$2$", [clockTime.hour, clockTime.min.format("%02d")]);
  33. dc.setColor(Graphics.COLOR_BLACK,Graphics.COLOR_TRANSPARENT);
  34. dc.drawText(dc.getWidth()/2,dc.getHeight()/2.06, font, timeString, Graphics.TEXT_JUSTIFY_CENTER|Graphics.TEXT_JUSTIFY_VCENTER);
  35. }
  36. // Called when this View is removed from the screen. Save the
  37. // state of this View here. This includes freeing resources from
  38. // memory.
  39. function onHide() as Void {}
  40.  
  41. // The user has just looked at their watch. Timers and animations may be started here.
  42. function onExitSleep() as Void {}
  43.  
  44. // Terminate any active timers and prepare for slow updates.
  45. function onEnterSleep() as Void {}
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement