Skip to content

Commit 9c6e08b

Browse files
author
botamochi6277
committed
Add face customization example
1 parent 981f319 commit 9c6e08b

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

examples/face-and-color/face-and-color.ino

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using namespace m5avatar;
77

88
Avatar avatar;
99

10-
Face* faces[5];
10+
Face* faces[6];
1111
const int num_faces = sizeof(faces) / sizeof(Face*);
1212
int face_idx = 0; // face index
1313

@@ -23,6 +23,23 @@ int palette_idx = 0;
2323

2424
bool isShowingQR = false;
2525

26+
// an example of customizing
27+
class MyCustomFace : public Face {
28+
public:
29+
MyCustomFace()
30+
: Face(new UShapeMouth(44, 44, 0, 16), new BoundingRect(222, 160),
31+
// right eye, second eye arg is center position of eye
32+
new EllipseEye(32, 32, false), new BoundingRect(163, 64),
33+
// left eye
34+
new EllipseEye(32, 32, true), new BoundingRect(163, 256),
35+
// right eyebrow
36+
// BowEyebrow's origin is the center of bow (arc)
37+
new BowEyebrow(64, 20, false),
38+
new BoundingRect(163, 64), // (y,x)
39+
// left eyebrow
40+
new BowEyebrow(64, 20, true), new BoundingRect(163, 256)) {}
41+
};
42+
2643
void setup() {
2744
M5.begin();
2845
M5.Lcd.setBrightness(30);
@@ -33,6 +50,7 @@ void setup() {
3350
faces[2] = new OmegaFace();
3451
faces[3] = new GirlyFace();
3552
faces[4] = new PinkDemonFace();
53+
faces[5] = new MyCustomFace();
3654

3755
color_palettes[0] = new ColorPalette();
3856
color_palettes[1] = new ColorPalette();

0 commit comments

Comments
 (0)