- UID
- 1656
- 麦力
- 10614
- 注册时间
- 2016-11-7
- 最后登录
- 2023-7-14
- 精华
- 8
- 阅读权限
- 80
- 在线时间
- 1040 小时
|
本帖最后由 qs100371 于 2017-4-27 09:33 编辑
指针就是画的线。要有形状必须自己计算表针外形的坐标,放在数组里,用的时候把坐标连成封闭的图形。手表的浮点数计算不行,不能实时计算这些坐标。
- /*表盘中心位置*/
- #define CX 64
- #define CY 64
- #define pi 3.1416
复制代码
- struct date_time dt;
- app_service_get_datetime(&dt);
- float h, m;
- h = (3 - dt.hour - (float)dt.min / 60) * pi * 30 / 180; //时针,分针和X轴(三点钟方向)的角度
- m = (15 - (float)dt.min) * pi * 90 / 180 / 15;
- Geometry *geometry[2];
- uint8_t num = 0;
- LayerGeometry layer_geometry;
- memset(geometry, 0, sizeof(geometry));
- Line lh = {{CX, CY}, {CX + 40*cos(h), CY - 40*sin(h)}};
- Geometry lg1 = {GeometryTypeLine, FillOutline, GColorBlack, (void*)&lh};
- geometry[num++] = &lg1;
- Line lm = {{CX, CY}, {CX + 60*cos(m), CY - 40*sin(m)}};
- Geometry lg2 = {GeometryTypeLine, FillOutline, GColorBlack, (void*)&lm};
- geometry[num++] = &lg2;
- layer_geometry.num = num;
- layer_geometry.p_g = geometry;
- p_layer = app_layer_create_geometry(&layer_geometry);
- app_window_add_layer(p_window, p_layer);
复制代码 这些代码只能在模拟器上执行
|
|