初始化内容
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
#pragma once
|
||||
|
||||
#include <dl.h>
|
||||
using namespace dl;
|
||||
|
||||
class UIGfx : public UI::Scene
|
||||
{
|
||||
public:
|
||||
UIGfx()
|
||||
{
|
||||
_panel = g_ui->CreatePanel();
|
||||
_panel->SetPosScale({ 0.0f, 0.0f });
|
||||
_panel->SetPosPixel(POS_CONTENT);
|
||||
_panel->SetAutoRun(false);
|
||||
|
||||
UI::Panel* panel_menu = g_ui->CreatePanel();
|
||||
panel_menu->SetLocator(createLocatorX(128, 4));
|
||||
g_ui->SetPanelParent(panel_menu, _panel);
|
||||
{
|
||||
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
|
||||
UI::ButtonStyle::LONG);
|
||||
btn->SetMode(UI::ButtonMode::RADIO);
|
||||
btn->SetString("点(dot)");
|
||||
panel_menu->Add(btn);
|
||||
}
|
||||
{
|
||||
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
|
||||
UI::ButtonStyle::LONG);
|
||||
btn->SetMode(UI::ButtonMode::RADIO);
|
||||
btn->SetString("线(line)");
|
||||
panel_menu->Add(btn);
|
||||
}
|
||||
{
|
||||
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
|
||||
UI::ButtonStyle::LONG);
|
||||
btn->SetMode(UI::ButtonMode::RADIO);
|
||||
btn->SetString("三角形(triangle)");
|
||||
panel_menu->Add(btn);
|
||||
}
|
||||
{
|
||||
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
|
||||
UI::ButtonStyle::LONG);
|
||||
btn->SetMode(UI::ButtonMode::RADIO);
|
||||
btn->SetString("四边形(quad)");
|
||||
panel_menu->Add(btn);
|
||||
}
|
||||
{
|
||||
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
|
||||
UI::ButtonStyle::LONG);
|
||||
btn->SetMode(UI::ButtonMode::RADIO);
|
||||
btn->SetString("正多边形(circle)");
|
||||
panel_menu->Add(btn);
|
||||
}
|
||||
{
|
||||
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
|
||||
UI::ButtonStyle::LONG);
|
||||
btn->SetMode(UI::ButtonMode::RADIO);
|
||||
btn->SetString("爱心");
|
||||
panel_menu->Add(btn);
|
||||
}
|
||||
_panelMenu = panel_menu;
|
||||
|
||||
_coorRender = Coor::Create(_panelMenu->GetCoorRef());
|
||||
_coorRender->SetPosition({ 200, 150 });
|
||||
}
|
||||
|
||||
virtual void Update() override
|
||||
{
|
||||
_panel->Update();
|
||||
}
|
||||
virtual void Render() override
|
||||
{
|
||||
g_gfx->RenderCoor(_coorRender, false);
|
||||
g_gfx->SetCoor(_coorRender);
|
||||
std::size_t i = _panelMenu->GetSelectIndex();
|
||||
if (i == 0)
|
||||
{
|
||||
for (int j = -10; j < 10; ++j)
|
||||
{
|
||||
for (int i = -10; i < 10; ++i)
|
||||
{
|
||||
g_gfx->SetColor(createColorRandom());
|
||||
g_gfx->Dot2D({ 10.0f * i, 10.0f * j });
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
g_gfx->SetColor({ ColorDef::RED, ColorDef::GREEN });
|
||||
g_gfx->Line2D({ -100, -100 }, { 100, 100 });
|
||||
g_gfx->SetColor({ ColorDef::WHITE, ColorDef::WHITE });
|
||||
g_gfx->Line2D({ 100, -100 }, { -100, 100 });
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
g_gfx->SetColor({ ColorDef::RED,
|
||||
ColorDef::GREEN,
|
||||
ColorDef::BLUE });
|
||||
g_gfx->Triangle2D({ -0, -50 }, { 50, 50 }, { -50, 50 });
|
||||
g_gfx->TriangleSolid2D(
|
||||
{ -0 + 200, -50 },
|
||||
{ 50 + 200, 50 },
|
||||
{ -50 + 200, 50 });
|
||||
}
|
||||
else if (i == 3)
|
||||
{
|
||||
g_gfx->SetColor({ ColorDef::RED, ColorDef::GREEN,
|
||||
ColorDef::BLUE, ColorDef::YELLOW });
|
||||
g_gfx->Quad2D(
|
||||
{ 0, -50 },
|
||||
{ 50, 0 },
|
||||
{ 0, 50 },
|
||||
{ -50, 0 });
|
||||
g_gfx->QuadSolid2D(
|
||||
{ 0 + 200, -50 },
|
||||
{ 50 + 200, 0 },
|
||||
{ 0 + 200, 50 },
|
||||
{ -50 + 200, 0 });
|
||||
}
|
||||
else if (i == 4)
|
||||
{
|
||||
std::vector<Color> vec_color;
|
||||
unsigned n = 33;
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
{
|
||||
vec_color.push_back(colorLerp((float)i / 32));
|
||||
}
|
||||
g_gfx->SetColor(vec_color);
|
||||
g_gfx->PolygonRegular2D({}, 64, 32);
|
||||
g_gfx->PolygonRegularSolid2D({200, 0}, 64, 32);
|
||||
}
|
||||
else if (i == 5)
|
||||
{
|
||||
g_gfx->SetColor({ ColorDef::RED, ColorDef::GREEN });
|
||||
g_gfx->Love();
|
||||
}
|
||||
|
||||
}
|
||||
~UIGfx()
|
||||
{
|
||||
delete _coorRender;
|
||||
}
|
||||
private:
|
||||
UI::Panel* _panel;
|
||||
UI::Panel* _panelMenu;
|
||||
Coor* _coorRender;
|
||||
};
|
||||
Reference in New Issue
Block a user