<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[problem with TFT_eSprite]]></title><description><![CDATA[<p dir="auto">Hi all<br />
I have a problem with sprites</p>
<p dir="auto">I have some objects that draw some circels, strings or line to the M5core2.</p>
<p dir="auto">I do that with the following code</p>
<pre><code>x = 230;
    uint32_t _r = r;  // 50
    uint32_t _w = _r * 2;
    uint32_t _h = _r * 2;

    TFT_eSprite _sprite = new TFT_eSprite(&amp;M5.Lcd);
    _sprite.createSprite(_w, _h);
    _sprite.drawCircle(_r, _r, _r, _color);
    _sprite.drawCircle(_r, _r, _r - 1, _color);
    _sprite.fillCircle(_r, _r, _r - 2, _colorCircle);

    _sprite.pushSprite(x - _r + 4, y - _r + 4);
    _sprite.deleteSprite();
</code></pre>
<p dir="auto">That works fine if x is lower than 230. As soon x is bigger than 230 every pixel that is outside 280 is trunccatet from the circle</p>
<p dir="auto">Any ideas or is thre a limitation with sprites?</p>
]]></description><link>https://community.m5stack.com/topic/6530/problem-with-tft_esprite</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 01:51:54 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6530.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Jun 2024 13:03:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to problem with TFT_eSprite on Mon, 14 Oct 2024 10:26:01 GMT]]></title><description><![CDATA[<p dir="auto">When x is larger than 230, the circle is pushed to a position where part of it exceeds the screen width (320 pixels wide), specifically beyond the x value of 280 (since your circle has a diameter of 100 pixels, calculated from _r = 50, and its center is at x - _r + 4).<br />
Sprites are typically clipped when drawn outside the screen area<a href="https://youtubechanneltranscripts.com/" target="_blank" rel="noopener noreferrer nofollow ugc">,</a> meaning any part of the sprite that extends beyond the screen boundary will not be displayed.</p>
<p dir="auto">To prevent the sprite from being truncated, you can implement a check to ensure that the sprite's position remains within the screen's boundaries before calling pushSprite.</p>
<p dir="auto">Here’s an updated version of your code:</p>
<pre><code>// Ensure the sprite stays within the screen's bounds
x = (x &gt; 270) ? 270 : x;  // Adjust x to stay within the screen width

uint32_t _r = r;  // 50
uint32_t _w = _r * 2;
uint32_t _h = _r * 2;

TFT_eSprite _sprite = new TFT_eSprite(&amp;M5.Lcd);
_sprite.createSprite(_w, _h);
_sprite.drawCircle(_r, _r, _r, _color);
_sprite.drawCircle(_r, _r, _r - 1, _color);
_sprite.fillCircle(_r, _r, _r - 2, _colorCircle);

// Push sprite only within the screen's bounds
_sprite.pushSprite(x - _r + 4, y - _r + 4);
_sprite.deleteSprite();

</code></pre>
]]></description><link>https://community.m5stack.com/post/26731</link><guid isPermaLink="true">https://community.m5stack.com/post/26731</guid><dc:creator><![CDATA[JudyLemoine]]></dc:creator><pubDate>Mon, 14 Oct 2024 10:26:01 GMT</pubDate></item><item><title><![CDATA[Reply to problem with TFT_eSprite on Tue, 04 Jun 2024 18:17:33 GMT]]></title><description><![CDATA[<p dir="auto">You don't show what Y is, or what your screen orientation is set to. If I remember correctly, if any part of a sprite gets pushed offscreen, the sprite will be truncated. So make sure the bounds of the sprite are within the 320 x 240 pixels of the LCD when you push it. The paramaters to pushSprite are the "upper left corner" of where you want the sprite to be placed.</p>
<p dir="auto">Look through the examples at <a href="https://github.com/m5stack/M5Stack/tree/master/examples/Advanced/Display/Sprite" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Stack/tree/master/examples/Advanced/Display/Sprite</a> to failiarize yourself.</p>
]]></description><link>https://community.m5stack.com/post/25481</link><guid isPermaLink="true">https://community.m5stack.com/post/25481</guid><dc:creator><![CDATA[wsanders]]></dc:creator><pubDate>Tue, 04 Jun 2024 18:17:33 GMT</pubDate></item></channel></rss>