0
페블 시계 표면에 textlayer 색상을 여러 가지 색상으로 설정할 수있는 방법이 있습니까? 예를 들어, 시간이 12시라면 1을 1 개의 색으로, 2를 두 번째 색으로, 1을 : 첫 번째 색으로, 등등으로합니다. 나는이 정보를 어디서나 찾을 수 없으며,이 방법은 하나의 변수만을 취하는 것으로 보인다.TextLayer MultiColor PebbleSDK
쉽게 할 수페블 시계 표면에 textlayer 색상을 여러 가지 색상으로 설정할 수있는 방법이 있습니까? 예를 들어, 시간이 12시라면 1을 1 개의 색으로, 2를 두 번째 색으로, 1을 : 첫 번째 색으로, 등등으로합니다. 나는이 정보를 어디서나 찾을 수 없으며,이 방법은 하나의 변수만을 취하는 것으로 보인다.TextLayer MultiColor PebbleSDK
쉽게 할 수, 당신은 예에서, 상황에 맞는 색상마다 변경해야
void time_update_callback(Layer *layer, GContext *ctx)
{
/* Get a layer rect to re-draw */
GRect layer_bounds = layer_get_bounds(layer);
/* Get time from variables */
char h1[2];
char h2[2];
char m1[2];
char m2[2];
h1[0] = hour_text_visible[0];
h2[0] = hour_text_visible[1];
m1[0] = minute_text_visible[0];
m2[0] = minute_text_visible[1];
h1[1] = h2[1] = m1[1] = m2[1] = 0;
/* Add y padding to GRect */
layer_bounds.origin.y += 1;
/* Aux copy */
GRect origin = layer_bounds;
/* Change color to Black */
graphics_context_set_text_color(ctx, GColorBlack);
/* Move */
layer_bounds.origin.x += 4;
layer_bounds.origin.y += 1;
/* Draw assuming you have a font loaded */
graphics_draw_text(ctx, h1, font, layer_bounds, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
/* Move again */
layer_bounds.origin.x += 20;
/* Draw black also */
graphics_draw_text(ctx, h2, font, layer_bounds, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
/* move */
layer_bounds.origin.x += 30;
/* Change color to Blue */
graphics_context_set_text_color(ctx, GColorBlue);
/* Draw in blue */
graphics_draw_text(ctx, m1, font, layer_bounds, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
/* etc */
}