2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

M5Unified・LovyanGFXでspriteを鏡像反転するには

Posted at

経緯

M5Stackで車のHUDを作ってみたいと思い、画面を鏡像反転させようとして、画面バッファに使っているspriteを反転させる方法がわからず調べ回ったので、メモです。

M5Toughで確認。

canvas.createSprite(M5.Display.width(), M5.Display.height());
// ~描画~
canvas.pushSprite(&M5.Display, 0, 0); //画面に反映

の場合において、pushSpriteをpushAffineに以下のように置き換える。

    // X倍率, 横傾, X座標, 縦傾, 縦倍率, Y座標
    //float matrix[6] = {1.0, 0.0,0.0, 0.0, 1.0, 0.0}; //正像
    //float matrix[6] = {1.0, 0.0,0.0, 0.0, -1.0, M5.Display.height()}; //垂直鏡像
    float matrix[6] = {-1.0, 0.0,M5.Display.width(), 0.0, 1.0, 0.0}; //水平鏡像
    canvas.pushAffine(&M5.Display,matrix);

参考資料

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?