C 带指针样式的时钟
#include <stdio.h>
#include <malloc.h>
#include<graphics.h>
#include<conio.h>
#define LEN sizeof(struct student)
#include "math.h"
#define PI 3.1415926
void Draw(int hour, int minute, int second)
{
double a_hour, a_min, a_sec; // 时、分、秒针的弧度值
int x_hour, y_hour, x_min, y_min, x_sec, y_sec; // 时、分、秒针的末端位置
// 计算时、分、秒针的弧度值
a_sec = second * 2 * PI / 60;
a_min = minute * 2 * PI / 60 + a_sec / 60;
a_hour= hour * 2 * PI / 12 + a_min / 12;
// 计算时、分、秒针的末端位置
x_sec = 320 + (int)(120 * sin(a_sec));
y_sec = 240 - (int)(120 * cos(a_sec));
x_min = 320 + (int)(100 * sin(a_min));
y_min = 240 - (int)(100 * cos(a_min));
x_hour= 320 + (int)(70 * sin(a_hour));
y_hour= 240 - (int)(70 * cos(a_hour));
// 画时针
setlinestyle(PS_SOLID, NULL,NULL, 10);
setcolor(WHITE);
line(320, 240, x_hour, y_hour);
// 画分针
setlinestyle(PS_SOLID,1, NULL, 6);
setcolor(LIGHTGRAY);
line(320, 240, x_min, y_min);
// 画秒针
setlinestyle(PS_SOLID,1, NULL, 2);
setcolor(RED);
line(320, 240, x_sec, y_sec);
}
void main()
{
initgraph(640, 480); // 初始化 640 x 480 的绘图窗口
// 绘制一个简单的表盘
//solidcircle(20, 40, 0xff);
circle(320, 240, 2);
circle(320, 240, 60);
circle(320, 240, 160);
//fillcircle (240, 320, BLUE);
outtextxy(296, 300, "LAOLISHI");
// 设置 XOR 绘图模式
setwritemode(R2_XORPEN); // 设置 XOR 绘图模式
// 绘制表针
SYSTEMTIME ti; // 定义变量保存当前时间
while(!kbhit()) // 按任意键退出钟表程序
{
GetLocalTime(&ti); // 获取当前时间
printf("%d%d%d",ti.wHour, ti.wMinute, ti.wSecond);
Draw(ti.wHour, ti.wMinute, ti.wSecond); // 画表针
Sleep(1000); // 延时 1 秒
printf("%d%d%d",ti.wHour, ti.wMinute, ti.wSecond);
Draw(ti.wHour, ti.wMinute, ti.wSecond); // 擦表针(擦表针和画表针的过程是一样的)
}
closegraph(); // 关闭绘图窗口
}
C 带指针样式的时钟的更多相关文章
- java生成带html样式的word文件
参考:http://blog.csdn.net/xiexl/article/details/6652230 最近在项目中需要将通过富文本编辑器处理过的文字转换为Word,查了很久,大家通常的解决办法是 ...
- css Cursor:url()自定义鼠标指针样式为图片
css自定义鼠标指针样式为图片Cursor:url()的使用,今天在项目中,要用到自定义鼠标样式,格式: css:{cursor:url('绝对路径的图片(格式:cur,ico)'),-moz-zoo ...
- AC自动机总结及板子(不带指针)
蒟蒻最近想学个AC自动机简直被网上的板子搞疯了,随便点开一个都是带指针的,然而平时用到指针的时候并不多,看到这些代码也完全是看不懂的状态.只好在大概理解后自己脑补(yy)了一下AC自动机的代码,居然还 ...
- 百度地图API显示多个标注点带百度样式信息检索窗口的代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- WPF 重写微调自带的样式,ListView、DataGrid、TreeView等所有控件的默认样式
不知道各位在开发中有没有遇到这样的窘迫,开发一个UI,设计给出的效果图和自带的样式的区别很大,然后有的样式通过属性是修改不了的,比如TreeView的子项TreeViewItem,想完全透明背景色就做 ...
- C++之不带指针类的设计——Boolean
经典的类设计分类 带指针类 不带指针类 Header文件的布局 #ifndef __COMPLEX__ #define __COMPLEX__ #include <iostream.h> ...
- Mac更换鼠标指针样式_mousecape教程
mousecape项目介绍 这是github上的一个项目,作者是alexzielenski. 项目是用于修改Mac系统鼠标样式的,支持动态鼠标样式. 该项目停止更新于2014年,目前仍可以被较新的系统 ...
- [c++] 面向对象课程(二)-- 带指针类的设计
class with pointer menbers string_test.cpp 1 #include "string.h" 2 #include <iostream&g ...
- Mac更换鼠标指针样式_ANI、CUR文件解析
前情提要 因为之前写了一篇mousecape的博客有一些回应,所以我决定写个续.主要是教大家怎么把cur文件和ani文件插入到mousecape里面,顺便提供几个做好的cape文件. 先给大家推荐一个 ...
随机推荐
- 转:perror和strerror的区别
概述: perror和strerror都是C语言提供的库函数,用于获取与erno相关的错误信息,区别不大,用法也简单.最大的区别在于perror向stderr输出结果,而 strerror向stdou ...
- 注意:rsyslog 源码安装 会出现日志重复发的情况,需要rpm包安装
cd /etc/yum.repos.d;wget http://rpms.adiscon.com/v8-stable/rsyslog.repo uat-web02:/etc/yum.repos.d# ...
- linux开源论坛
开源资源: 开源http://oss.org.cn/?action-news http://www.lupaworld.com/proj.php http://www.10pig.cn/linux/o ...
- 【转】Android:ListView常见错位之CheckBox错位
原文网址:http://blog.csdn.net/lemon_tree12138/article/details/39337867 ListView在什么样的情况下会出现错位?错位的原因是什么?怎么 ...
- WinForm ListControl MouseWheel Envent
最近在使用Listbox开发程序的时候, 遇到MouseWheel event 异常. 设置如下: 1. DrawModel:ownerDrawVariable. 2. InternalHeight: ...
- Ubuntu中apt-get出现E:Encountered a section with no Package: header……的解决方案
方法一:运行命令apt-get update更新list列表 方法二:将/var/lib/apt/lists/下的所有list文件都删除,然后再update
- jquery1.7.2的源码分析(五)$.support
$.support 的英文注释很详细的介绍的这里,就稍微的写了下 Query.support = (function() { var support, all, a, select, opt, inp ...
- IOS XMPP
http://www.cnblogs.com/lmyhao/p/4120616.html
- [Angular 2] @Input Custom public property naming
TodoList.ts: @Component({ selector: 'todo-list', directives: [TodoItemRenderer], template: ` <ul& ...
- [Typescript] Typescript Enums vs Booleans when Handling State
Handling state with Typescript enums, instead of booleans, is preferred because:- Enums are more rea ...