📄 matrixblitter.h
字号:
/*
Copyright (c) 2001
Author: Konstantin Boukreev
E-mail: konstantin@mail.primorye.ru
Created: 18.12.2001 11:30:52
Version: 1.0.0
emulates the Matrix code you can see on Dozer's screens in the movie
but it can draw a streams of code in any colour :)
*/
#ifndef _MatrixBlitter_0439143c_d325_4172_a227_f7f548951fd8
#define _MatrixBlitter_0439143c_d325_4172_a227_f7f548951fd8
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "HSVModel.h"
class MatrixBlitter
{
public:
typedef char (*fn_GetChar)(int);
private:
HDC m_hdc;
HBITMAP m_bmp;
HBITMAP m_unused;
HFONT m_font;
HFONT m_font2;
bool m_font_owner;
bool m_font2_owner;
HBRUSH m_brush;
HSLModel m_hsl;
HSLModel m_hsl2;
unsigned m_bcolor;
unsigned m_cx;
unsigned m_cy;
unsigned m_height;
unsigned m_width;
unsigned m_char_cx;
unsigned m_char_cy;
unsigned m_total;
unsigned m_now;
unsigned m_speed1;
unsigned m_speed2;
float m_damping;
void * m_raw_mem;
fn_GetChar m_fnGetChar;
struct stream
{
stream (unsigned pos, unsigned length, unsigned speed, HSLModel hsl, HSLModel hs2);
#ifdef _DEBUG
unsigned debug_trap;
#endif
unsigned x;
unsigned y;
int delay;
unsigned speed;
unsigned color;
unsigned color2;
bool hidden;
char code[1];
static unsigned shift (HSLModel hsl);
};
typedef std::vector<stream *> streams_t;
streams_t m_streams;
public:
MatrixBlitter(fn_GetChar = GetChar);
~MatrixBlitter();
void Init(HDC, unsigned, unsigned, unsigned);
void Blit(HDC, int, int);
void Refresh();
void Render();
void Clear();
//
void SetSpeed (unsigned s1, unsigned s2) { m_speed1 = s1; m_speed2 = s2; }
void SetFont (HFONT);
void SetHeadFont (HFONT);
void SetColor (unsigned color) { m_hsl.rgb(color); }
void SetHeadColor (unsigned color) { m_hsl2.rgb(color); }
void SetBackColor (unsigned color);
void SetActivity (float f) { m_now = (unsigned)(m_total * f); }
void SetDamping (float f) { m_damping = 1.f - f; }
private:
void Generate();
void UpdateStream(stream *);
public:
static char GetChar(int x)
{
x; // unused
static char alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-@#*&?!";
return alpha[rand() % sizeof(alpha)];
}
};
#endif //_MatrixBlitter_0439143c_d325_4172_a227_f7f548951fd8
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -