Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize clock and clock with graphical Interface based on EasyX Library in C language

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "C language based on EasyX library how to achieve graphical interface watches", in the daily operation, I believe that many people in the C language based on EasyX library how to achieve graphical interface clocks have doubts, Xiaobian consulted all kinds of data, sorted out a simple and easy-to-use method of operation, hope to answer the "C language based on EasyX library how to achieve graphical interface watches" doubt is helpful! Next, please follow the editor to study!

1. Target requirements:

Implement a clock that displays an image

2.C language code: # include / / need to download the EasyX library # include#include#include#include#include#define High 480#define Width 640 / canvas size # define PI 3.1415 * in advance to realize the rotation of the second hand. SecondAngle is defined as the angle corresponding to the second hand, and the terminal coordinates of the second hand are obtained by using the knowledge of trigonometric geometry. SecondEnd_ x = center_ x + secondLength * sin (secondAngle); secondEnd_ y = center_ y-secondLength * cos (secondAngle); let the angle secondAngle cycle change, that is to achieve the second hand rotation animation effect. * / void HideCursor () {/ / hide the cursor position, this function will do CONSOLE_CURSOR_INFO cursor_info= {1 STD_OUTPUT_HANDLE 0}; SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), & cursor_info);} whether int IsEnd;// ends int center_x,center_y;// midpoint int second_long;// length int second_x,second_y;// second hand position int minute_long;// length int minute_x,minute_y / / minute position int hour_long;// length int hour_x,hour_y;// hour hand position int second_num,minute_num,hour_num;// second hand hour hand void startup () {/ / [data initialization] HideCursor (); / / do not display cursor IsEnd = 0; initgraph (Width,High); / / display canvas center_x=Width/2; center_y=High/2 / / Center point information second_long= (Width > High)? High/4:Width/4; second_x=center_x; second_y = center_y-second_long;// second hand information minute_long=second_long*4/5; minute_x=center_x; minute_y = center_y-minute_long;// minute hand information hour_long=second_long*2/3; hour_x=center_x; hour_y = center_y-hour_long;// hour hand information second_num=0; minute_num=0 Hour_num=0;} void show_begin () {/ / [initial page display] BeginBatchDraw (); / / start of batch drawing} void show () {/ / [display screen] int i; setlinestyle (PS_SOLID,2); / / set the linetype to solid and the lineweight to 2 setcolor (DARKGRAY); / / set the color to dark gray setfillcolor (DARKGRAY) / / set the fill color to dark gray fillcircle (center_x,center_y,second_long*5/4); / / draw the dial outer circle setcolor (LIGHTGRAY); / / set the color light gray setfillcolor (LIGHTGRAY); / / set the fill color to light gray fillcircle (center_x,center_y,second_long*6/5); / / fill the dial background for

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report