原理
把文本输出到 IMAGE 中,再使其在屏幕上滚动。
在文字向上滚动的同时,相应地压缩每行的像素,并且改变每行的亮度,就实现了 3D 效果。
效果
源码
//
// 编译环境:Visual Studio 2022 | EasyX
#include <easyx.h>
#include <time.h>
#include <stdio.h>
// 窗口宽高
int nWindowWidth = 1280;
int nWindowHeight = 480;
int font_h = 200; // 文字高
int font_w = 20; // 文字宽
short nStartLightness = 255; // 初始亮度
short nEndLightness = 60; // 最终亮度
float fEndWidthRatio = (float)0.65; // 宽度缩放比例
float fEndHeightRatio = (float)0.3; // 高度缩放比例
int fps = 24; // 帧率
int nAmount = 2; // 文字单次位移
// 文本
wchar_t pszText[] =
L"Irish Song\n"
L"The star may dissolve, and the fountain of light\n"
L"May sink intoe'er ending chao's and night,\n"
L"O