stackchan-display
Loading...
Searching...
No Matches
Faces.h
1
#pragma once
2
3
#include "FacialDrawable.h"
4
#include "Eyes.h"
5
#include "Mouthes.h"
6
7
namespace
stackchan::display
8
{
9
10
// Stack-chan default face
11
// [・_・]
12
class
Face
:
public
FacialDrawable
13
{
14
protected
:
15
// auto blink parameters
16
bool
is_auto_blink_ =
true
;
17
uint32_t auto_blink_interval_ = 3000;
// 3 second
18
uint32_t last_blink_time_ = 0;
19
uint32_t blink_duration_ = 200;
// 0.2 seconds, which is the duration of closed eye
20
21
float
breath_frequency_ = 0.25f;
// in Hz,
22
23
// child facial components
24
// NOTE: use object pointers for exchanging components
25
BaseEye
*left_eye_;
26
BaseEye
*right_eye_;
27
BaseMouth
*mouth_;
28
29
public
:
30
Face
();
31
Face
(
BaseEye
*left_eye,
32
BaseEye
*right_eye,
33
BaseMouth
*mouth);
34
35
BaseEye
*getLeftEye()
36
{
37
return
left_eye_;
38
}
39
40
BaseEye
*getRightEye()
41
{
42
return
right_eye_;
43
}
44
45
BaseMouth
*getMouth()
46
{
47
return
mouth_;
48
}
49
50
void
activateAutoBlink()
51
{
52
is_auto_blink_ =
true
;
53
}
54
void
deactivateAutoBlink()
55
{
56
is_auto_blink_ =
false
;
57
}
58
bool
getIsAutoBlink()
59
{
60
return
is_auto_blink_;
61
}
62
63
void
autoScale();
64
65
virtual
void
updateState(
ExpressionWeight
&expression_weight);
66
virtual
void
draw(M5Canvas &canvas,
ExpressionWeight
&expression_weight,
ColorPalette
&palette)
override
;
67
// virtual void update() override;
68
};
69
70
// custom faces
71
72
// [O O]
73
class
EllFace
:
public
Face
74
{
75
public
:
76
EllFace
() :
Face
(
77
new
EllipseEye
(160 + 160 / 2, 240 / 2, 320 / 5, 320 / 5 * 3,
true
),
78
new
EllipseEye
(160 - 160 / 2, 240 / 2, 320 / 5, 320 / 5 * 3,
false
),
79
new
BaseMouth
(0, 0, 0, 0)) {};
80
};
81
82
// [OωO]
83
class
OmegaFace
:
public
Face
84
{
85
public
:
86
OmegaFace
() :
Face
(
87
new
EllipseEye
(84 + 154, 165, 36, 70,
true
),
88
new
EllipseEye
(84, 165, 36, 70,
false
),
89
new
OmegaMouth
(160, 225, 72, 30)) {};
90
};
91
92
}
// namespace stackchan::display
stackchan::display::BaseEye
Base class for Eye, draw nothing.
Definition
Eyes.h:22
stackchan::display::BaseMouth
Definition
Mouthes.h:7
stackchan::display::ColorPalette
Definition
ColorPalette.h:48
stackchan::display::EllFace
Definition
Faces.h:74
stackchan::display::EllipseEye
Definition
Eyes.h:54
stackchan::display::ExpressionWeight
Definition
Expression.h:39
stackchan::display::Face
Definition
Faces.h:13
stackchan::display::FacialDrawable
Definition
FacialDrawable.h:11
stackchan::display::OmegaFace
Definition
Faces.h:84
stackchan::display::OmegaMouth
Definition
Mouthes.h:27
src
faces
Faces.h
Generated by
1.12.0