シャボン玉
https://scrapbox.io/files/64414733f2bfbd001bd62db9.png
使い方
SoapBubble(Circle 円, ColorF 色);
※指定する色はアルファ値を小さくした方が良いです。
※沢山表示するときは色を少しずつ変えた方が良いです。
用途
背景やエフェクトなどにどうぞ。
コード
code:シャボン玉.cpp
# include <Siv3D.hpp>
void SoapBubble(const Circle& circle, const ColorF& color)
{
circle.draw(ColorF(1, 0), color).drawFrame(2, 0, ColorF(1, 0.5));
Circle{ circle.center.x - circle.r * 0.4,circle.center.y - circle.r * 0.4,circle.r * 0.3 }.draw(ColorF(1, 0.5));
}
void Main()
{
Scene::SetBackground(Palette::Skyblue);
Array<Circle>bubbles(30);
for (auto& bubble : bubbles)
{
bubble = Circle{ RandomVec2(800, 600) ,Random(30, 100) };
}
while (System::Update())
{
{
SoapBubble(bubble, HSV{ Scene::Time() * 60 + i * 30,0.1 });
}
}
}
https://scrapbox.io/files/693bb5bfb977dc6b6aba3397.png
アイコンとして活用することもできます。
code:シャボン玉アイコン.cpp
# include <Siv3D.hpp>
void SoapBubble(const Circle& circle, const ColorF& color)
{
circle.draw(ColorF(1, 0), color).drawFrame(2, 0, ColorF(1, 0.5));
Circle{ circle.center.x - circle.r * 0.4,circle.center.y - circle.r * 0.4,circle.r * 0.3 }.draw(ColorF(1, 0.5));
}
void Main()
{
Scene::SetBackground(Palette::Skyblue);
Array<Texture>icons{ Texture{0xF4AD_icon,60},Texture{0xF129_icon,60},Texture{0xF128_icon,60},Texture{0xF041_icon,60}, };
Array<Circle>bubbles(icons.size());
for (int32 i = 0; i < bubbles.size(); ++i)
{
bubblesi = Circle{ 100 + i * 140,100,50 }; }
while (System::Update())
{
for (int32 i=0;i<icons.size();++i)
{
iconsi.drawAt(bubblesi.center); SoapBubble(bubblesi, HSV{Scene::Time() * 60 + i * 90,0.1}); }
}
}