WinAPI——谐振动的合成
#include<Windows.h>
#include<math.h> #define NUM 1000
#define PI 3.14159 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) ;
void Draw(HWND) ; static int cxClient, cyClient, xOffset, yOffset;
POINT apt[NUM] ;
static int A = ; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT("谐振动合成") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ; wndclass.cbClsExtra = NULL ;
wndclass.cbWndExtra = NULL ;
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH) ;
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW) ;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION) ;
wndclass.hInstance = hInstance ;
wndclass.lpfnWndProc = WndProc ;
wndclass.lpszClassName = szAppName ;
wndclass.lpszMenuName = NULL ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ; if(!RegisterClass(&wndclass))
{
MessageBox(NULL, TEXT("This Program Requires Windows NT !"), szAppName, MB_ICONERROR) ;
return ;
} hwnd = CreateWindow(szAppName, TEXT("谐振动合成"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ;
ShowWindow(hwnd, iCmdShow) ;
UpdateWindow(hwnd) ; while(TRUE)
{
if(PeekMessage(&msg, NULL, , , PM_REMOVE))
{
if(msg.message == WM_QUIT)
break ;
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
else
{
Draw(hwnd) ;
}
}
return msg.wParam ;
} LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ switch(message)
{
case WM_SIZE :
cxClient = LOWORD(lParam) ;
cyClient = HIWORD(lParam) ;
xOffset = cxClient / ;
yOffset = cyClient / ;
A = xOffset < yOffset ? xOffset : yOffset ; return ; case WM_DESTROY :
PostQuitMessage() ;
return ;
}
return DefWindowProc(hwnd, message, wParam, lParam) ;
} void Draw(HWND hwnd)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
int t ;
static double w1 = , w2 = ; // w1 : w2 = 1 : 2
static double g = PI / ; // 初相位之差 hdc = GetDC(hwnd) ; apt[].x = xOffset ;
apt[].y = yOffset + A * sin(g) ;
MoveToEx(hdc, apt[].x, apt[].y, NULL) ;
for(t = ; t < NUM ; t++)
{
apt[t].x = xOffset + A * sin(t * * w1 * w2 * PI /( NUM * w1 ));
apt[t].y = yOffset + A * sin(t * * w1 * w2 * PI /( NUM * w2 ) + g ) ;
LineTo(hdc, apt[t].x, apt[t].y) ;
MoveToEx(hdc, apt[t].x, apt[t].y, NULL) ;
}
// Polyline(hdc, apt, NUM ) ; rect.bottom = cyClient ;
rect.left = ;
rect.right = cxClient ;
rect.top = ; // Sleep(1000) ;
// w1 ++ ;
// w2 ++ ;
// g += PI / 4 ;
// InvalidateRect(hwnd, &rect, TRUE) ; ReleaseDC(hwnd, hdc) ;
}
WinAPI——谐振动的合成的更多相关文章
- H5项目开发分享——用Canvas合成文字
以前曾用Canvas合成.裁剪.图片等<用H5中的Canvas等技术制作海报>.这次用Canvas来画文字. 下图中"老王考到驾照后"这几个字是画在Canvas上的,与 ...
- 设计模式之合成/聚合利用原则(CARP)
一.概念 CARP:CompositionAggregation Principle 合成聚合复用原则,尽量使用合成/聚合,尽量不使用类继承.合成聚合是“has a”的关系,而继承是“is a”的 ...
- .a静态库构架合成
一.如果类库生成的构架和对应设备的构架不一致,会链接报错 如果项目中使用类库后,遇到形似Undefined symbols for architecture x86_64(x86_64架构下有未定义的 ...
- 二维码合成,将苹果和安卓(ios和android)合成一个二维码,让用户扫描一个二维码就可以分别下载苹果和安卓的应用
因为公司推广的原因,没有合适的将苹果和安卓(ios和android)合成一个二维码的工具. 因为这个不难,主要是根据浏览器的UA进行判断,所以就自己开发了一个网站 网站名称叫:好推二维码 https ...
- UWP图片编辑器(涂鸦、裁剪、合成)
一.编辑器简介 写这个控件之前总想找一找开源的,可以偷下懒省点事.可是各种地方都搜遍了也没有找到. 于是,那就做第一个吃螃蟹的人吧! 控件主要有三个功能:涂鸦.裁剪.合成. 涂鸦:主要是用到了InkT ...
- compass Sprites 雪碧图 小图片合成[Sass和compass学习笔记]
demo 源码 地址 https://github.com/qqqzhch/webfans 什么是雪碧图? CSS雪碧 即CSS Sprites,也有人叫它CSS精灵,是一种CSS图像合并技术,该方法 ...
- 常用的WinAPI函数整理
常用的WinAPI函数整理 一.进程 创建进程: CreateProcess("C:\\windows\\notepad.exe",0,0,0,0,0,0,0,&s ...
- C# 图片的裁剪,两个图片合成一个图片
图片的裁剪,两个图片合成一个图片(这是从网上摘的) /// <summary> /// 图片裁剪,生成新图,保存在同一目录下,名字加_new,格式1.png 新图1_ne ...
- 动画animation的三个应用(漂浮的白云、旋转的星球、正方体合成)
× 目录 [1]漂浮的白云 [2]旋转的星球 [3]正方体合成 前面的话 前面介绍过动画animation的详细用法,本文主要介绍动画animation的三个效果 漂浮的白云 [效果演示] [简要介绍 ...
随机推荐
- jQuery操作cookie
验证jquery的cookie插件时才知道原先文件一直在桌面上放着执行发现没有效果,文件必须放在web服务器下面执行才会生效,晕菜! $.cookie(name,value,{expires: 7,p ...
- Linux命令——创建删除文件
创建文件夹 mkdir filename 进入目录文件 cd filename 返回上一级目录 cd ..返回多级目录 cd ../../.. (../表示一级) 创建文件 touch filen ...
- jQuery判断浏览器
在jQuery1.9版本之前,jQuery 提供了 browser 标记 <script type="text/javascript" src="http://aj ...
- python getpass模块:隐藏不显示输入的密码
不知道为什么,本机测试必须要在debug模式下才正常运行.. import getpass #用于隐藏用户输入的字符串,常用来接收密码 def checkuser(user,passwd): ': r ...
- linux kernel
first step. http://www.cyberciti.biz/faq/howto-install-kernel-headers-package/ http://uliweb.clkg.or ...
- Android调用Asp.net Web Service示例
WebService代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; u ...
- js类型判断及鸭式辨型
目录 instanceof constructor 构造函数名字 鸭式辨型 三种检测对象的类方式: instanceof.constructor .构造函数名字 用法如下: 1)instanceof ...
- Word Ladder——LeetCode
Given two words (start and end), and a dictionary, find the length of shortest transformation sequen ...
- JAVA中的Transient
Java中的transient,是用于声明序列化的时候不被存储的. 例子: package ThreadTest; /** * Created with IntelliJ IDEA. * User: ...
- [LeetCode] 205. Isomorphic Strings 解题思路 - Java
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...