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

╄→尐↘猪︶ㄣ 提交于 2019-12-24 07:15:05

问题


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:


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();


来源:https://stackoverflow.com/questions/26984473/how-to-add-an-image-to-a-window-in-pebble-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!