如何在Pebble.js中向窗口添加图像? [英] How to add an image to a window in Pebble.js?

查看:98
本文介绍了如何在Pebble.js中向窗口添加图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

窗口文档( http://developer.getpebble.com/docs/pebblejs/#window )表示我们可以向其中添加图片:

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

窗口:窗口本身是最灵活的.它允许您添加不同的元素(圆形,图像,矩形,文本,TimeText),并为每个元素指定位置和大小.还可以为其设置动画."

"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."

图像是一个元素,但是图像构造函数上没有任何文档.它需要什么参数?特别是,我们如何指定图像src?此外,也没有将图像添加到窗口的示例代码.

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.

推荐答案

我们仍在努力改进Pebble.js及其文档,但是与此同时,这应该使您开始使用Pebble.js添加图片:

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

这篇关于如何在Pebble.js中向窗口添加图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆