Last active
August 31, 2018 06:42
-
-
Save 1a57danc3/a70fa5edcaa6ba8e3a67 to your computer and use it in GitHub Desktop.
R.O.C flag in cpp+c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in CPP------------------ | |
unsigned int CPixelBlueSkyWhiteSun::CalculatePixel(unsigned int x, unsigned int y) | |
{ unsigned int red = 0xffff0000; | |
unsigned int white = 0xffffffff; | |
unsigned int blue = 0xff0000ff; | |
float w = m_width*0.5f; | |
float h = m_height*0.5f; | |
if ((float)x > w || (float)y > h) | |
{ | |
return red; | |
} | |
float cX = w*0.5f; | |
float cY = h*0.5f; | |
float radius = cY*0.5f; | |
Vec2 tri0(0.0f, -radius*1.65f); | |
Vec2 tri1(-radius*0.2f, -radius*1.05f); Vec2 tri2(radius*0.2f, -radius*1.05f); | |
Vec2 P; | |
float i = x - cX; | |
float j = y - cY; | |
float dis = sqrtf(i*i + j*j); | |
if (dis < radius) | |
{ | |
return white; | |
} | |
else if (dis > radius*1.65f) | |
{ | |
return blue; | |
} | |
for (int m = 0; m < 12; m++) | |
{ | |
P.x = i*m_list_cos[m] - j*m_list_sin[m]; | |
P.y = i*m_list_sin[m] + j*m_list_cos[m]; | |
if (IsPointInTriangle(tri0, tri1, tri2, P)) | |
{ | |
return white; | |
} | |
} | |
return blue; | |
} | |
in C Sharp------------------------------ | |
class CPixelBlueSkyWhiteSun : public IPixelEquation | |
{ | |
public: | |
CPixelBlueSkyWhiteSun() | |
{ | |
m_width = 1680; | |
m_height = 1120; | |
for (int i = 0; i < 12; i++) | |
{ | |
m_list_sin[i] = sinf(i*PI/6); | |
m_list_cos[i] = cosf(i*PI/6); | |
} | |
} | |
const char* GetName() const | |
{ return "Blue Sky White Sun"; } | |
unsigned int CalculatePixel(unsigned int x, unsigned int y); | |
private: float m_list_sin[12]; float m_list_cos[12]; }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment