How to add an image to a window in Pebble.js?

1k views Asked by At

The documentation on window (http://developer.getpebble.com/docs/pebblejs/#window) says that we can add an image to it:

"Window: The Window by itself is the most flexible. It allows you to add different Elements (Circle, Image, Rect, Text, TimeText) and to specify a position and size for each of them. You can also animate them."

An image is an element, but there is no documentation on the image constructor. What parameters does it take? Particularly, how do we specify the image src? Also, there is no example code of adding an image to a window.

1

There are 1 answers

1
girlgrammer On BEST ANSWER

We're still working on improving Pebble.js and its documentation, but in the meantime, this should get you started with adding Images with Pebble.js:

var UI = require('ui');

var logo_image = new UI.Image({
  position: new Vector2(0, 0),
  size: new Vector2(144, 144),
  backgroundColor: 'clear',
  image: 'images/logo_image.png',
});

wind.add(logo_image);
wind.show();