Skip to content

Commit

Permalink
keira: add transform demo
Browse files Browse the repository at this point in the history
  • Loading branch information
and3rson committed Mar 11, 2024
1 parent f4c8e49 commit 8531301
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions firmware/keira/src/apps/demos/transform.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "transform.h"

TransformApp::TransformApp() : App("Transform") {
}

void TransformApp::run() {
lilka::Image* face = lilka::resources.loadImage("/sd/face.bmp");

int x = canvas->width() / 2 - face->width / 2;
int y = canvas->height() / 2 - face->height / 2;

int angle = 0;

while (1) {
canvas->fillScreen(canvas->color565(0, 0, 0));
lilka::Transform transform = lilka::Transform().rotate(angle);
canvas->drawImageTransformed(face, x, y, transform);
queueDraw();
angle++;

lilka::State state = lilka::controller.getState();
if (state.a.justPressed) {
return;
}
}
}
11 changes: 11 additions & 0 deletions firmware/keira/src/apps/demos/transform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include "app.h"

class TransformApp : public App {
public:
TransformApp();

private:
void run() override;
};
3 changes: 3 additions & 0 deletions firmware/keira/src/apps/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "demos/lines.h"
#include "demos/disk.h"
#include "demos/ball.h"
#include "demos/transform.h"
#include "demos/epilepsy.h"
#include "demos/letris.h"
#include "demos/user_spi.h"
Expand Down Expand Up @@ -68,6 +69,7 @@ void LauncherApp::appsMenu() {
String titles[] = {
"Лінії",
"Шайба",
"Перетворення",
"М'ячик",
"Епілепсія",
"Летріс",
Expand All @@ -80,6 +82,7 @@ void LauncherApp::appsMenu() {
APP_CLASS_LIST classes = {
APP_CLASS(DemoLines),
APP_CLASS(DiskApp),
APP_CLASS(TransformApp),
APP_CLASS(BallApp),
APP_CLASS(EpilepsyApp),
APP_CLASS(LetrisApp),
Expand Down

0 comments on commit 8531301

Please sign in to comment.