GithubHelp home page GithubHelp logo

Comments (5)

patfelst avatar patfelst commented on May 26, 2024 1

Thanks. I didn't know you could push a sprite to display in another sprite. I don't need to do it now, but am curious. Would it work like this?

#include <M5Unified.h>

M5Canvas SpriteA;
M5Canvas SpriteB;

void setup(void)
{
  M5.begin();
  SpriteA.createSprite(32, 32);
  SpriteA.drawCircle(16, 16, 10, TFT_WHITE);

  SpriteB.createSprite(100, 100);
  SpriteA.pushSprite(&SpriteB, 32, 32); // Draw SpriteA inside SpriteB
  SpriteB.pushSprite(&M5.Display, 0, 0);
}

from m5unified.

lovyan03 avatar lovyan03 commented on May 26, 2024 1

@patfelst
Yes, that's correct.
If you are interested, take a look at the LovyanGFX sample.

https://github.com/lovyan03/LovyanGFX/blob/0.4.7/examples/Sprite/ClockSample/ClockSample.ino

The entity of M5.Display is the M5GFX library, and M5GFX is a wrapping of LovyanGFX.

from m5unified.

patfelst avatar patfelst commented on May 26, 2024

Actually they all compile, but the first and last both cuase the ESP32 to crash. The middle one works ok.

from m5unified.

lovyan03 avatar lovyan03 commented on May 26, 2024

@patfelst
It is as per the specification.
When using pushSprite, you can set the output destination as the first argument.
In other words, in addition to output from M5Canvas to M5.Display, you can also output from M5Canvas to other M5Canvas.
If you specify the output destination in the constructor argument, you do not need to specify the output destination when using pushSprite, but you can specify the output destination if necessary.
In other words, if you omit the output destination in the constructor argument, you must always specify the output destination as the first argument when using pushSprite.

#include <M5Unified.h>

M5Canvas canvas;   // Omit the output destination

void setup(void)
{
  M5.begin();
  canvas.createSprite(32, 32);
  canvas.drawCircle(16, 16, 10, TFT_WHITE);

  canvas.pushSprite(&M5.Display, 32, 32);  // OK

//canvas.pushSprite( 64, 64);  // Crash !
}

from m5unified.

patfelst avatar patfelst commented on May 26, 2024

Wow that clock example will take some study. But I get the idea of what you're doing with the sprites.

from m5unified.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.