Finished Oving 7
parent
7ca45b26e5
commit
0bd4c9e51c
|
@ -19,10 +19,8 @@ void Face::attach_to(Graph_lib::Window& win)
|
|||
#pragma region EmptyFace
|
||||
|
||||
EmptyFace::EmptyFace(Point p, int r) : Face(p, r),
|
||||
//leftEye{ Point{ p.x - int(sqrt(2) / 4 * r), p.y - int(sqrt(2) / 4 * r) }, r / 10 },
|
||||
//rightEye{ Point { p.x + int(sqrt(2) / 4 * r), p.y - int(sqrt(2) / 4 * r) }, r / 10 }
|
||||
leftEye{ Point{ p.x - r / 2, p.y - r / 2 }, r / 10 },
|
||||
rightEye{ Point { p.x + r / 2, p.y - r / 2 }, r / 10 }
|
||||
leftEye{ Point{ p.x - r / 2, p.y - r / 8 }, r / 10 },
|
||||
rightEye{ Point { p.x + r / 2, p.y - r / 8 }, r / 10 }
|
||||
{
|
||||
|
||||
leftEye.set_fill_color(Color::black);
|
||||
|
@ -76,6 +74,7 @@ void SadFace::attach_to(Graph_lib::Window & win)
|
|||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region AngryFace
|
||||
|
||||
AngryFace::AngryFace(Point p, int r) : EmptyFace{ p,r },
|
||||
|
@ -104,6 +103,7 @@ void AngryFace::attach_to(Graph_lib::Window & win)
|
|||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region WinkingFace
|
||||
|
||||
WinkingFace::WinkingFace(Point p, int r) : Face(p, r),
|
||||
|
@ -136,3 +136,26 @@ void WinkingFace::attach_to(Graph_lib::Window & win)
|
|||
|
||||
#pragma endregion
|
||||
|
||||
AwkwardFace::AwkwardFace(Point p, int r) : Face{p, r},
|
||||
leftEye{Point{p.x - 4 * r / 5, p.y}, r / 10},
|
||||
rightEye{Point{p.x + 4 * r / 5, p.y}, r / 10}
|
||||
{
|
||||
leftEye.set_fill_color(Color::black);
|
||||
rightEye.set_fill_color(Color::black);
|
||||
|
||||
leftEye.set_color(Color::black);
|
||||
rightEye.set_color(Color::black);
|
||||
|
||||
mouth.add(Point{ p.x - r / 2, p.y + r / 25 });
|
||||
mouth.add(Point{ p.x + r / 2, p.y + r / 25 });
|
||||
mouth.set_color(Color::black);
|
||||
mouth.set_style(Line_style(Line_style::solid, 3));
|
||||
}
|
||||
|
||||
void AwkwardFace::attach_to(Graph_lib::Window & win)
|
||||
{
|
||||
Face::attach_to(win);
|
||||
win.attach(leftEye);
|
||||
win.attach(rightEye);
|
||||
win.attach(mouth);
|
||||
}
|
||||
|
|
|
@ -100,4 +100,14 @@ private:
|
|||
Open_polyline wink;
|
||||
int x1,x2;
|
||||
int y1, y2, y3;
|
||||
};
|
||||
|
||||
class AwkwardFace : public Face
|
||||
{
|
||||
public:
|
||||
AwkwardFace(Point p, int r);
|
||||
void attach_to(Graph_lib::Window& win) override;
|
||||
private:
|
||||
Circle leftEye, rightEye;
|
||||
Open_polyline mouth;
|
||||
};
|
|
@ -2,9 +2,11 @@
|
|||
#include "Emoji.h"
|
||||
|
||||
// Size of window and emoji radius
|
||||
constexpr int xmax = 1000;
|
||||
constexpr int ymax = 600;
|
||||
constexpr int emojiRadius = 100;
|
||||
constexpr int xmax = 750;
|
||||
constexpr int ymax = 200;
|
||||
constexpr int emojiRadius = 50;
|
||||
|
||||
void DrawEmojies(Vector_ref<Emoji>& emojis, Graph_lib::Window& win);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -13,14 +15,23 @@ int main()
|
|||
const Point tl{100, 100};
|
||||
const string win_label{"Emoji factory"};
|
||||
Simple_window win{tl, xmax, ymax, win_label};
|
||||
AngryFace face(Point{ 200, 200 }, emojiRadius);
|
||||
|
||||
face.attach_to(win);
|
||||
|
||||
/* TODO:
|
||||
* - initialize emojis
|
||||
* - connect emojis to window
|
||||
**/
|
||||
Vector_ref<Emoji> emoji;
|
||||
emoji.push_back(new EmptyFace(Point{ 100, 100 }, emojiRadius));
|
||||
emoji.push_back(new SmileyFace(Point{ 210, 100 }, emojiRadius));
|
||||
emoji.push_back(new SadFace(Point{ 320, 100 }, emojiRadius));
|
||||
emoji.push_back(new AngryFace(Point{ 430, 100 }, emojiRadius));
|
||||
emoji.push_back(new WinkingFace(Point{ 540, 100 }, emojiRadius));
|
||||
emoji.push_back(new AwkwardFace(Point{ 650, 100 }, emojiRadius));
|
||||
|
||||
DrawEmojies(emoji, win);
|
||||
|
||||
win.wait_for_button();
|
||||
}
|
||||
|
||||
void DrawEmojies(Vector_ref<Emoji>& emojis, Graph_lib::Window & win)
|
||||
{
|
||||
for (const auto e : emojis)
|
||||
{
|
||||
e->attach_to(win);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue