• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sin_lookup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sin_lookup函数的典型用法代码示例。如果您正苦于以下问题:C++ sin_lookup函数的具体用法?C++ sin_lookup怎么用?C++ sin_lookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sin_lookup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: second_display_layer_update_callback

void second_display_layer_update_callback(Layer *me, GContext* ctx) {
	(void) me;

	time_t now = time(NULL);
	struct tm *t = localtime(&now);

	int32_t second_angle = t->tm_sec * (0xffff / 60);
	int second_hand_length = 70;
	GPoint center = grect_center_point(&GRECT_FULL_WINDOW);
	GPoint second = GPoint(center.x, center.y - second_hand_length);

	if (init_anim < ANIM_SECONDS) {
		second = GPoint(center.x, center.y - 70);
	} else if (init_anim == ANIM_SECONDS) {
		second_angle_anim += 0xffff / 60;
		if (second_angle_anim >= second_angle) {
			init_anim = ANIM_DONE;
			second =
					GPoint(center.x + second_hand_length * sin_lookup(second_angle)/0xffff,
							center.y + (-second_hand_length) * cos_lookup(second_angle)/0xffff);
		} else {
			second =
					GPoint(center.x + second_hand_length * sin_lookup(second_angle_anim)/0xffff,
							center.y + (-second_hand_length) * cos_lookup(second_angle_anim)/0xffff);
		}
	} else {
		second =
				GPoint(center.x + second_hand_length * sin_lookup(second_angle)/0xffff,
						center.y + (-second_hand_length) * cos_lookup(second_angle)/0xffff);
	}

	graphics_context_set_stroke_color(ctx, GColorWhite);

	graphics_draw_line(ctx, center, second);
}
开发者ID:yatul,项目名称:ModernExtra20,代码行数:35,代码来源:main.c


示例2: second_display_layer_update_callback

void second_display_layer_update_callback(Layer *me, GContext* ctx) {
  (void)me;

  PblTm t;
  get_time(&t);

  int32_t second_angle = t.tm_sec * (0xffff/60);
  int32_t counter_second_angle = t.tm_sec * (0xffff/60);
  if(t.tm_sec<30)
  {
     counter_second_angle += 0xffff/2;
  }
  else
  {
     counter_second_angle -= 0xffff/2;
  }
  int second_hand_length = 60;
  int counter_second_hand_length = 15;

  graphics_context_set_fill_color(ctx, GColorWhite);

  GPoint center = grect_center_point(&me->frame);
  GPoint counter_second = GPoint(center.x + counter_second_hand_length * sin_lookup(counter_second_angle)/0xffff,
				center.y + (-counter_second_hand_length) * cos_lookup(counter_second_angle)/0xffff);
  GPoint second = GPoint(center.x + second_hand_length * sin_lookup(second_angle)/0xffff,
				center.y + (-second_hand_length) * cos_lookup(second_angle)/0xffff);

  graphics_draw_line(ctx, counter_second, second);
}
开发者ID:performa62,项目名称:pebble,代码行数:29,代码来源:speed.c


示例3: update_scale

static void update_scale(Layer *layer, GContext *context) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = GPoint(bounds.size.w / 2, bounds.size.h / 2);

  graphics_context_set_stroke_color(context, GColorWhite);
  
  GPoint start;
  GPoint end;
  
  for( int i = 0; i < 12; ++i) {
    int32_t current_angle = TRIG_MAX_ANGLE * i / 12;
    
    // create an oval shape indicator start point
    start.x = (sin_lookup(current_angle) * 65 / TRIG_MAX_RATIO) + center.x;
    start.y = (-cos_lookup(current_angle) * 75 / TRIG_MAX_RATIO) + center.y;
    end.x = (sin_lookup(current_angle) * 100 / TRIG_MAX_RATIO) + center.x;
    end.y = (-cos_lookup(current_angle) * 100 / TRIG_MAX_RATIO) + center.y;

    if (i % 3  == 0) {
      // reached a quarter, draw bigger indicator
      graphics_context_set_stroke_width(context, 6);
    } else {
      graphics_context_set_stroke_width(context, 3);
    }

    graphics_draw_line(context, start, end);          
  }
}
开发者ID:mariobodemann,项目名称:pebble-ace-face,代码行数:28,代码来源:main.c


示例4: update_time

static void update_time() {
  // Get a tm structure
  time_t temp = time(NULL); 
  struct tm *t = localtime(&temp);
  srand((unsigned) time(&temp));
  static PropertyAnimation *s_min_animation, *s_hour_animation, *s_ufo_animation;
  static GRect min_from_frame, min_to_frame, hour_to_frame, hour_from_frame, ufo_to_frame, ufo_from_frame;
  static int x1ufo, x2ufo, y1ufo, y2ufo;
  
  int min_distance   = 64;
  int hour_distance  = 40;
  int32_t min_angle  = TRIG_MAX_ANGLE * t->tm_min/60;
  int32_t hour_angle = (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6);
  
  xmin = (int16_t)(sin_lookup(min_angle)    * min_distance  / TRIG_MAX_RATIO) + 72 - 16;
  ymin = (int16_t)(-cos_lookup(min_angle)   * min_distance  / TRIG_MAX_RATIO) + 86 - 16;
  xhour = (int16_t)(sin_lookup(hour_angle)  * hour_distance / TRIG_MAX_RATIO) + 72 - 14;
  yhour = (int16_t)(-cos_lookup(hour_angle) * hour_distance / TRIG_MAX_RATIO) + 86 - 14;
  
  min_from_frame  = GRect(oldxmin, oldymin, 32, 32);
  min_to_frame    = GRect(xmin, ymin, 32, 32);
  
  hour_from_frame = GRect(oldxhour, oldyhour, 28,28);
  hour_to_frame   = GRect(xhour, yhour, 28,28);
  
  s_min_animation = property_animation_create_layer_frame((Layer *)s_min_layer, &min_from_frame, &min_to_frame);
  animation_set_duration((Animation *)s_min_animation,1000);
  
  
  s_hour_animation = property_animation_create_layer_frame((Layer *)s_hour_layer, &hour_from_frame, &hour_to_frame);
  animation_set_duration((Animation *)s_hour_animation,1000);

  animation_set_handlers((Animation*) s_min_animation, (AnimationHandlers) {
    .stopped = (AnimationStoppedHandler) animation_sunmoon_stopped,
  }, NULL);
开发者ID:kristofwillen,项目名称:Pebble-Galileo,代码行数:35,代码来源:main.c


示例5: hands_update_proc

static void hands_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  const int16_t hourHandLength = bounds.size.w / 2 +20;
  const int16_t minuteHandLength = hourHandLength - 30;

  GPoint minuteHand;
  center.y +=20;

  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  for (int i=0;i<12;i++)
  {
    int16_t minute_angle = TRIG_MAX_ANGLE * (((59-t->tm_min)+i*5)%60) / 60;
    minuteHand.y = (int16_t)(-cos_lookup(minute_angle) * (int32_t)minuteHandLength / TRIG_MAX_RATIO) + center.y;
    minuteHand.x = (int16_t)(sin_lookup(minute_angle) * (int32_t)minuteHandLength / TRIG_MAX_RATIO) + center.x;

    GRect frame = layer_get_frame(text_layer_get_layer(num_layer[i]));
    frame.origin.x = minuteHand.x-frame.size.w/2;
    frame.origin.y = minuteHand.y-frame.size.h/2;
    layer_set_frame(text_layer_get_layer(num_layer[i]),frame);
    layer_set_hidden(text_layer_get_layer(num_layer[i]),false);
    
    int16_t hour_angle = (TRIG_MAX_ANGLE * (((24-t->tm_hour+i) % 12) * 6) +
                         ((TRIG_MAX_ANGLE * (60-t->tm_min)) / 10))     / (12 * 6);
    minuteHand.y = (int16_t)(-cos_lookup(hour_angle) * (int32_t)hourHandLength / TRIG_MAX_RATIO) + center.y;
    minuteHand.x = (int16_t)(sin_lookup(hour_angle) * (int32_t)hourHandLength / TRIG_MAX_RATIO) + center.x;
    
    frame = layer_get_frame(text_layer_get_layer(hour_layer[i]));
    frame.origin.x = minuteHand.x-frame.size.w/2;
    frame.origin.y = minuteHand.y-frame.size.h/2;
    layer_set_frame(text_layer_get_layer(hour_layer[i]),frame);
    layer_set_hidden(text_layer_get_layer(hour_layer[i]),false);

  }
  
  // draw minute line
  if(getDrawline())
  {
    if(getInvert())
      graphics_context_set_stroke_color(ctx,GColorWhite);
    else
      graphics_context_set_stroke_color(ctx,GColorBlack);
    graphics_draw_line(ctx,GPoint(144/2,0),GPoint(144/2,167));
  }
  // draw background
  transbitmap_draw_in_rect(background_bitmap, ctx, bounds);
  
  // draw date
  if(draw_date)
  {
    graphics_context_set_fill_color(ctx,GColorBlack);
    graphics_fill_circle(ctx,GPoint(120,120),16);
    layer_set_hidden(text_layer_get_layer(date_layer),false);
  }
  else
    layer_set_hidden(text_layer_get_layer(date_layer),true);
}
开发者ID:reini1305,项目名称:pastpresentfuture,代码行数:59,代码来源:ppf.c


示例6: rotate

void rotate(uint16_t ang,GPoint *p)
{
  ang-=0x4000;
  int16_t ox=p->x;
  int16_t oy=p->y;
  
  p->x=(sin_lookup(ang)*ox/TRIG_MAX_RATIO)+(cos_lookup(ang)*oy/TRIG_MAX_RATIO);
  p->y=(-cos_lookup(ang)*ox/TRIG_MAX_RATIO)+(sin_lookup(ang)*oy/TRIG_MAX_RATIO);
  
}
开发者ID:an-ox,项目名称:bbc,代码行数:10,代码来源:moo10.c


示例7: update_main_proc

static void update_main_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(s_main_layer);
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, bounds, 0, GCornerNone);
  if(s_is_running) {
    show_round_meter(ctx, &bounds);
  }

  graphics_context_set_antialiased(ctx, ANTIALIASING);

  Time mode_time;
  srand(time(NULL));
  time_t t = time(NULL);
  struct tm *time_now = localtime(&t);
  mode_time.hours = time_now->tm_hour;
  mode_time.minutes = time_now->tm_min;
  
  // Adjust for minutes through the hour
  float minute_angle = TRIG_MAX_ANGLE * mode_time.minutes / 60;
  float hour_angle = TRIG_MAX_ANGLE * mode_time.hours / 12;

  hour_angle += (minute_angle / TRIG_MAX_ANGLE) * (TRIG_MAX_ANGLE / 12);

  // Plot hands
  GPoint minute_hand = (GPoint) {
    .x = (int16_t)(sin_lookup(TRIG_MAX_ANGLE * mode_time.minutes / 60 ) * (int32_t)(HAND_RADIUS - HAND_MARGIN) / TRIG_MAX_RATIO) + s_center.x,
    .y = (int16_t)(-cos_lookup(TRIG_MAX_ANGLE * mode_time.minutes / 60) * (int32_t)(HAND_RADIUS - HAND_MARGIN) / TRIG_MAX_RATIO) + s_center.y,
  };
  GPoint hour_hand = (GPoint) {
    .x = (int16_t)(sin_lookup(hour_angle) * (int32_t)(HAND_RADIUS - (2 * HAND_MARGIN)) / TRIG_MAX_RATIO) + s_center.x,
    .y = (int16_t)(-cos_lookup(hour_angle) * (int32_t)(HAND_RADIUS - (2 * HAND_MARGIN)) / TRIG_MAX_RATIO) + s_center.y,
  };
  
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_context_set_stroke_width(ctx, 4);
  // Draw hands with positive length only
  if(HAND_RADIUS > 2 * HAND_MARGIN) {
    graphics_draw_line(ctx, s_center, hour_hand);
  }
  if(HAND_RADIUS > HAND_MARGIN) {
    graphics_draw_line(ctx, s_center, minute_hand);
  }
 
  // center dot
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_fill_circle(ctx, s_center, 7);
}

static void main_select_click_handler(ClickRecognizerRef recognizer, void *context) {
  window_stack_push(s_menu_window, false);
}

static void main_click_config_provider(void *context) {
  window_single_click_subscribe(BUTTON_ID_SELECT, main_select_click_handler);
}
开发者ID:jojonki,项目名称:pomodoro,代码行数:55,代码来源:pomodoro.c


示例8: batteryLineArc

void batteryLineArc(GContext *ctx, float start_angle, float end_angle, GPoint centre, int radius, int thickness){
	
	float minus_bit = radius - thickness/2 + 0.5;// + (user_battery_colour <= 1 ? 0.5 : 0); //add 0.5 for the int casting, later !!! dark colours like 1.0, light better with 0.5
	float add_bit = (radius + thickness/2 + 0.5); 
	
	graphics_context_set_stroke_width(ctx, 1);
	
	if (start_angle == 0) {
		start_angle = 2.5;	// for some reason, 0 seems to start too far to the left....at least for my purposes
	}
	
	for (float i = start_angle; i <= end_angle; i+=0.5) {
		
		GPoint inside_point = (GPoint) {
			.x = (int16_t)(sin_lookup(i * TRIG_MAX_ANGLE / 360) * minus_bit / TRIG_MAX_RATIO) + centre.x,
			.y = (int16_t)(-cos_lookup(i * TRIG_MAX_ANGLE / 360) * minus_bit / TRIG_MAX_RATIO) + centre.y,
		};

		GPoint outside_point = (GPoint) {
			.x = (int16_t)(sin_lookup(i * TRIG_MAX_ANGLE / 360) * add_bit / TRIG_MAX_RATIO) + centre.x,
			.y = (int16_t)(-cos_lookup(i * TRIG_MAX_ANGLE / 360) * add_bit / TRIG_MAX_RATIO) + centre.y,
		};
		
		graphics_draw_line(ctx, inside_point, outside_point);
	}
}


/*************************** AnimationImplementation **************************/

static void animation_started(Animation *anim, void *context) {
  s_animating = true;
}

static void animation_stopped(Animation *anim, bool stopped, void *context) {
  s_animating = false;
}

static void animate(int duration, int delay, AnimationImplementation *implementation, bool handlers) {
  Animation *anim = animation_create();
  animation_set_duration(anim, duration);
  animation_set_delay(anim, delay);
  animation_set_curve(anim, AnimationCurveEaseInOut);
  animation_set_implementation(anim, implementation);
  
	if(handlers) {
    animation_set_handlers(anim, (AnimationHandlers) {
      .started = animation_started,
      .stopped = animation_stopped
    }, NULL);
  }
  animation_schedule(anim);
}
开发者ID:tdsbtoes,项目名称:OldFogies,代码行数:53,代码来源:ks-clock-face.c


示例9: Graphics_RenderCircle

void Graphics_RenderCircle(u16 CentreX, u16 CentreY, u16 Radius, u16 colour, TFT *TftPtr){
	double x, y, old_x, old_y;
	int i = 0;
	x = (Radius*(cos_lookup(i))) + CentreX;
	y = (Radius*(sin_lookup(i))) + CentreY;
	for(i = SIN_DIV; i<=360; i = i+SIN_DIV){
		old_x = x;
		old_y = y;
		x = (Radius*(cos_lookup(i))) + CentreX;
		y = (Radius*(sin_lookup(i))) + CentreY;
		render_line(old_x, old_y, x, y, colour, TftPtr);
	}
}
开发者ID:rzhao01,项目名称:ECE532_Project,代码行数:13,代码来源:graphics.c


示例10: anim_update

static void anim_update(Animation *animation, const AnimationProgress progress) {
    int max_angle = TRIG_MAX_ANGLE / 8;

    int angle_left = TRIG_MAX_ANGLE / 4 + (max_angle * progress) / ANIMATION_NORMALIZED_MAX;
    int angle_right = TRIG_MAX_ANGLE / 4 - (max_angle * progress) / ANIMATION_NORMALIZED_MAX;
    int length_left = (left_length * progress) / ANIMATION_NORMALIZED_MAX;
    int length_right = (right_length * progress) / ANIMATION_NORMALIZED_MAX;
    left_end = GPoint(left_start.x + (cos_lookup(angle_left) * length_left) / TRIG_MAX_RATIO,
                      left_start.y - (sin_lookup(angle_left) * length_left) / TRIG_MAX_RATIO);

    right_end = GPoint(right_start.x + (cos_lookup(angle_right) * length_right) / TRIG_MAX_RATIO,
                       right_start.y - (sin_lookup(angle_right) * length_right) / TRIG_MAX_RATIO);
    layer_mark_dirty(graphics_layer);
}
开发者ID:gaudima,项目名称:metro-spb,代码行数:14,代码来源:UpdateWindow.c


示例11: draw_compass_face

void draw_compass_face(void) {
  int32_t starx = 0;
  int32_t stary = 0;
  if (orientToHeading) {
    starx = center.x;
    stary = center.y-63;
  } else if (heading>=0) {
    starx = center.x + 63 * sin_lookup(TRIG_MAX_ANGLE * heading / 360 + orientation)/TRIG_MAX_RATIO;
    stary = center.y - 63 * cos_lookup(TRIG_MAX_ANGLE * heading / 360 + orientation)/TRIG_MAX_RATIO;
  }    
  layer_set_frame((Layer *) star_layer, GRect(starx - 14, stary - 18, 28, 28));
  int32_t nx = center.x + 63 * sin_lookup(orientation)/TRIG_MAX_RATIO;
  int32_t ny = center.y - 63 * cos_lookup(orientation)/TRIG_MAX_RATIO;
#ifndef PBL_COLOR
  if (orientToHeading && (abs(nx-starx)<10) && (abs(ny-stary)<10))
    text_layer_set_text(n_layer, "");
  else
#endif
    text_layer_set_text(n_layer, "N");
  layer_set_frame((Layer *) n_layer, GRect(nx - 14, ny - 18, 28, 28));
  int32_t ex = center.x + 63 * sin_lookup(orientation + TRIG_MAX_ANGLE/4)/TRIG_MAX_RATIO;
  int32_t ey = center.y - 63 * cos_lookup(orientation + TRIG_MAX_ANGLE/4)/TRIG_MAX_RATIO;
#ifndef PBL_COLOR
  if (orientToHeading && (abs(ex-starx)<10) && (abs(ey-stary)<10))
    text_layer_set_text(e_layer, "");
  else
#endif
    text_layer_set_text(e_layer, "E");
  layer_set_frame((Layer *) e_layer, GRect(ex - 14, ey - 18, 28, 28));
  int32_t sx = center.x + 63 * sin_lookup(orientation + TRIG_MAX_ANGLE/2)/TRIG_MAX_RATIO;
  int32_t sy = center.y - 63 * cos_lookup(orientation + TRIG_MAX_ANGLE/2)/TRIG_MAX_RATIO;
#ifndef PBL_COLOR
  if (orientToHeading && (abs(sx-starx)<10) &&  (abs(sy-stary)<10))
    text_layer_set_text(s_layer, "");
  else
#endif
    text_layer_set_text(s_layer, "S");
  layer_set_frame((Layer *) s_layer, GRect(sx - 14, sy - 18, 28, 28));
  int32_t wx = center.x + 63 * sin_lookup(orientation + TRIG_MAX_ANGLE*3/4)/TRIG_MAX_RATIO;
  int32_t wy = center.y - 63 * cos_lookup(orientation + TRIG_MAX_ANGLE*3/4)/TRIG_MAX_RATIO;
#ifndef PBL_COLOR
  if (orientToHeading && (abs(wx-starx)<10) &&  (abs(wy-stary)<10))
    text_layer_set_text(w_layer, "");
  else
#endif
    text_layer_set_text(w_layer, "W");
  layer_set_frame((Layer *) w_layer, GRect(wx - 14, wy - 18, 28, 28));
  layer_mark_dirty(head_layer);
}
开发者ID:edmund-k,项目名称:pebble-geocachingpro-back,代码行数:49,代码来源:GetBack.c


示例12: set_hand_angle

void set_hand_angle(RotBmpPairContainer *hand_image_container, unsigned int hand_angle, GPoint offset) {
  signed short x_fudge = 0;
  signed short y_fudge = 0;

  unsigned int pebble_angle = TRIG_MAX_ANGLE * hand_angle / 360;

  x_fudge += offset.x * cos_lookup(pebble_angle) / TRIG_MAX_RATIO - offset.y * sin_lookup(pebble_angle) / TRIG_MAX_RATIO;
  y_fudge += offset.x * sin_lookup(pebble_angle) / TRIG_MAX_RATIO + offset.y * cos_lookup(pebble_angle) / TRIG_MAX_RATIO;

  // (144 = screen width, 168 = screen height)
  hand_image_container->layer.layer.frame.origin.x = (144/2) - (hand_image_container->layer.layer.frame.size.w/2) + x_fudge;
  hand_image_container->layer.layer.frame.origin.y = (168/2) - (hand_image_container->layer.layer.frame.size.h/2) + y_fudge;

  layer_mark_dirty(&hand_image_container->layer.layer);
}
开发者ID:juliengrenier,项目名称:pebble,代码行数:15,代码来源:orbit.c


示例13: set_hand_text

void set_hand_text(TextLayer *text_layer, unsigned int hand_angle, char *text, GPoint offset, GSize size) {
  signed short x_fudge = (144/2);
  signed short y_fudge = (168/2);

  unsigned int pebble_angle = TRIG_MAX_ANGLE * hand_angle / 360;

  x_fudge += offset.x * cos_lookup(pebble_angle) / TRIG_MAX_RATIO - offset.y * sin_lookup(pebble_angle) / TRIG_MAX_RATIO;
  y_fudge += offset.x * sin_lookup(pebble_angle) / TRIG_MAX_RATIO + offset.y * cos_lookup(pebble_angle) / TRIG_MAX_RATIO;

  x_fudge -= size.w / 2;
  y_fudge -= size.h / 2;

  layer_set_frame(&text_layer->layer, GRect(x_fudge, y_fudge, size.w, size.h));
  text_layer_set_text(text_layer, text);
}
开发者ID:juliengrenier,项目名称:pebble,代码行数:15,代码来源:orbit.c


示例14: startup_animation_init

void startup_animation_init() {
  update_angles();
  hour_delta = GPoint(
    DOTS_RADIUS * sin_lookup(hour_angle) / ONE,
    -DOTS_RADIUS * cos_lookup(hour_angle) / ONE);
  gpath_move_to(hour_path, GPoint(CENTER_X + hour_delta.x, CENTER_Y + hour_delta.y));
  min_delta = GPoint(
    DOTS_RADIUS * sin_lookup(min_angle) / ONE,
    -DOTS_RADIUS * cos_lookup(min_angle) / ONE);
  gpath_move_to(min_path, GPoint(CENTER_X + min_delta.x, CENTER_Y + min_delta.y));
  sec_delta = GPoint(
    DOTS_RADIUS * sin_lookup(sec_angle) / ONE,
    -DOTS_RADIUS * cos_lookup(sec_angle) / ONE);
  gpath_move_to(sec_path, GPoint(CENTER_X + sec_delta.x, CENTER_Y + sec_delta.y));
}
开发者ID:ProggroP,项目名称:pebbleone,代码行数:15,代码来源:pebble_one.c


示例15: hands_update_proc

static void hands_update_proc(Layer* me, GContext* ctx) {
  const GPoint center = grect_center_point(&me->bounds);
  const int16_t secondHandLength = me->bounds.size.w / 2;

  GPoint secondHand;

  PblTm t;
  get_time(&t);

  int32_t second_angle = TRIG_MAX_ANGLE * t.tm_sec / 60;
  secondHand.y = (int16_t)(-cos_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.y;
  secondHand.x = (int16_t)(sin_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.x;

  // second hand
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_draw_line(ctx, secondHand, center);

  // minute/hour hand
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_stroke_color(ctx, GColorBlack);

  gpath_rotate_to(&s_data.minute_arrow, TRIG_MAX_ANGLE * t.tm_min / 60);
  gpath_draw_filled(ctx, &s_data.minute_arrow);
  gpath_draw_outline(ctx, &s_data.minute_arrow);

  gpath_rotate_to(&s_data.hour_arrow, (TRIG_MAX_ANGLE * (((t.tm_hour % 12) * 6) + (t.tm_min / 10))) / (12 * 6));
  gpath_draw_filled(ctx, &s_data.hour_arrow);
  gpath_draw_outline(ctx, &s_data.hour_arrow);

  // dot in the middle
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, GRect(me->bounds.size.w / 2-1, me->bounds.size.h / 2-1, 3, 3), 0, GCornerNone);
}
开发者ID:KenBauer,项目名称:pebble-sdk-examples,代码行数:33,代码来源:simple_analog.c


示例16: cos_lookup

/**
*
* Look up cos value from a table
*
* @param 	i, angle in degrees
*
******************************************************************************/
double cos_lookup(double i){
	if(i>270)
		i = i - 270;
	else
		i = i + 90;
	return sin_lookup(i);
}
开发者ID:rzhao01,项目名称:ECE532_Project,代码行数:14,代码来源:graphics.c


示例17: gpath_draw_outline_antialiased

void gpath_draw_outline_antialiased(GContext* ctx, GPath *path, GColor8 stroke_color){
	if(path->num_points == 0)
		return;	

	GPoint offset = path->offset;
	int32_t rotation = path->rotation;
	GBitmap* bitmap = graphics_capture_frame_buffer(ctx);

  	int32_t s = sin_lookup(rotation);
  	int32_t c = cos_lookup(rotation);

	GPoint p = path->points[path->num_points-1];
	GPoint p1;
  	p1.x = (p.x * c - p.y * s) / TRIG_MAX_RATIO + offset.x;
  	p1.y = (p.x * s + p.y * c) / TRIG_MAX_RATIO + offset.y;

	for(uint32_t i=0; i<path->num_points; i++){
		GPoint p2;
		p2.x = (path->points[i].x * c - path->points[i].y * s) / TRIG_MAX_RATIO  + offset.x;
		p2.y = (path->points[i].x * s + path->points[i].y * c) / TRIG_MAX_RATIO  + offset.y;
		draw_line_antialias_(bitmap, p1.x, p1.y, p2.x, p2.y, stroke_color);
		p1 = p2;
	}

	graphics_release_frame_buffer(ctx, bitmap);
}
开发者ID:Quikrobot,项目名称:rosewright,代码行数:26,代码来源:antialiasing.c


示例18: update_triangle_proc

static void update_triangle_proc(Layer *layer, GContext *ctx) {
  if(!s_spinning) {
    return;
  }
  
  // Move
  int32_t move_x = (int32_t)(sin_lookup(angle) * (RADIUS - 4) / TRIG_MAX_RATIO);
  int32_t move_y = (int32_t)(-cos_lookup(angle) * (RADIUS - 4) / TRIG_MAX_RATIO);
  gpath_move_to(s_spin_arrow_path, GPoint(s_spin_circle_center.x - move_x, s_spin_circle_center.y + move_y));
  
  if(TESTING){
    APP_LOG(APP_LOG_LEVEL_DEBUG, "move_x: %d", (int)move_x);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "move_y: %d", (int)move_y);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "angle: %d", (int)TRIGANGLE_TO_DEG(angle));
  }
  
  // Rotate
  gpath_rotate_to(s_spin_triangle_path, -angle);
  gpath_rotate_to(s_spin_arrow_path, -angle);
  
  // Fill the path:
  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, s_spin_triangle_path);
  graphics_context_set_fill_color(ctx, GColorWhite);
  gpath_draw_filled(ctx, s_spin_arrow_path);
}
开发者ID:watadarkstar,项目名称:pebble-spin-me,代码行数:26,代码来源:wakeup.c


示例19: hands_update_proc

static void hands_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  const int16_t second_hand_length = PBL_IF_ROUND_ELSE((bounds.size.w / 2) - 19, bounds.size.w / 2);

  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  // minute/hour hand
  // 時
  graphics_context_set_stroke_color(ctx, s_backColor);

  graphics_context_set_fill_color(ctx, s_hourHandColor);
  gpath_rotate_to(s_hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6));
  gpath_draw_filled(ctx, s_hour_arrow);
  // 分
  graphics_context_set_fill_color(ctx, s_backColor);
  gpath_rotate_to(s_minute_arrow, (TRIG_MAX_ANGLE * (t->tm_min * 10 + (t->tm_sec/6)) / (60 * 10)));
  graphics_context_set_stroke_width(ctx, 2);
  graphics_context_set_stroke_color(ctx, s_minuteHandColor);
  gpath_draw_outline(ctx, s_minute_arrow);

  // 秒
  int32_t second_angle = TRIG_MAX_ANGLE * t->tm_sec / 60;
  GPoint second_hand = {
    .x = (int16_t)(sin_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.x,
    .y = (int16_t)(-cos_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.y,
  };
if (s_show_seconds_hand){
    // second hand
    graphics_context_set_stroke_width(ctx, 3);
    graphics_context_set_stroke_color(ctx, s_secondHandColor);
    graphics_draw_line(ctx, second_hand, center);
    graphics_context_set_stroke_width(ctx, 1);
    graphics_context_set_stroke_color(ctx, s_backColor);
    graphics_draw_line(ctx, second_hand, center);
  }
  // dot in the middle
  // 黒に設定
  graphics_context_set_fill_color(ctx, s_backColor);
  // 円を塗り潰し
  graphics_fill_circle(ctx, center, 7);
  // 線の色を白に設定
  graphics_context_set_stroke_color(ctx, s_secondHandColor);
  graphics_context_set_stroke_width(ctx, 1);
  graphics_draw_circle(ctx, center, 7);
  graphics_draw_circle(ctx, center, 1);
  
}

static void date_update_proc(Layer *layer, GContext *ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  strftime(s_day_buffer, sizeof(s_day_buffer), "%a", t);
  text_layer_set_text(s_day_label, s_day_buffer);

  strftime(s_num_buffer, sizeof(s_num_buffer), "%d", t);
  text_layer_set_text(s_num_label, s_num_buffer);
}
开发者ID:bake-san,项目名称:ANALOG-P-SHOCK,代码行数:60,代码来源:simple_analog.c


示例20: minute_display_layer_update_callback

static void minute_display_layer_update_callback(Layer *layer, GContext* ctx) {

  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  unsigned int angle = t->tm_min * 6;

  GRect bounds = layer_get_bounds(layer);
  GRect min_rect;
  GPoint center = grect_center_point(&bounds);
  
  GPoint min_center; // center of the minute circle
  min_center.x = sin_lookup((TRIG_MAX_ANGLE / 360) * angle)*54/TRIG_MAX_RATIO + center.x;
  min_center.y = -cos_lookup((TRIG_MAX_ANGLE / 360) * angle)*54/TRIG_MAX_RATIO + center.y;
  graphics_context_set_fill_color(ctx, FOREGROUND_COLOR);
  graphics_context_set_stroke_color(ctx, FOREGROUND_COLOR);
  graphics_fill_circle(ctx, min_center, 17);
  
  strftime(min_text,sizeof(hour_text),"%M",t);

  min_rect.origin.x = min_center.x - 15;
  min_rect.origin.y = min_center.y - 18;
  min_rect.size.w = 30;
  min_rect.size.h = 15;
  graphics_context_set_text_color(ctx,BACKGROUND_COLOR);
  graphics_draw_text(ctx,min_text,fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD),min_rect,GTextOverflowModeWordWrap,GTextAlignmentCenter,NULL);
}
开发者ID:Prieni,项目名称:revolving,代码行数:27,代码来源:main.c



注:本文中的sin_lookup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sincos函数代码示例发布时间:2022-05-30
下一篇:
C++ sin函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap