# Why is screen.fill not showing the correct color?

**URL:** <https://forum.makecode.com/t/why-is-screen-fill-not-showing-the-correct-color/33506>\
**Category:** Help\
**Created:** [January 31, 2025, 3:35am UTC](https://forum.makecode.com/t/why-is-screen-fill-not-showing-the-correct-color/33506 "2025-01-31T03:35:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renderthegreat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/renderthegreat/32/19022_2.png) [@Renderthegreat](https://forum.makecode.com/u/Renderthegreat)\
**Post date:** [January 31, 2025, 3:35am UTC](https://forum.makecode.com/t/why-is-screen-fill-not-showing-the-correct-color/33506/1 "2025-01-31T03:35:01Z")

</div>

So I have this function

```auto
if (colorString[0] == '#') {
                const hex = colorString.replace('#', '');
                let r = parseInt(hex.slice(0, 2), 16);
                let g = parseInt(hex.slice(2, 4), 16);
                let b = parseInt(hex.slice(4, 6), 16);
                return color.rgb(r, g, b);
            };

```

And I call it here:

```auto
screen.fillRect(posX, posY, width + padding * 2, height + padding * 2, Style.color(backgroundColor));

```

where screen.fillRect is a function that adds a handler to draw that rectangle every frame. But when I use the function the wrong colors appear. This can be minimized by multiplying by four, but it does still leave a lot of error. Is there a solution to this problem?

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [January 31, 2025, 10:47pm UTC](https://forum.makecode.com/t/why-is-screen-fill-not-showing-the-correct-color/33506/2 "2025-01-31T22:47:55Z")

</div>

Hello! It looks like you are using PyGame? This forum is for Makecode Arcade. We can’t use more than 16 colors in Arcade, so a lot of people here have no idea what you are trying to do!  
The only thing I can see online is that using the .replace method isn’t what people usually do, so maybe it’s doing something weird?  
Maybe one of the [@moderators](https://forum.makecode.com/groups/moderators) can help?

---

<div class="post-metadata">

**Author:** ![Renderthegreat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/renderthegreat/32/19022_2.png) [@Renderthegreat](https://forum.makecode.com/u/Renderthegreat)\
**Post date:** [January 31, 2025, 11:57pm UTC](https://forum.makecode.com/t/why-is-screen-fill-not-showing-the-correct-color/33506/3 "2025-01-31T23:57:06Z")

</div>

This code is for PXT arcade with typescript.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [February 1, 2025, 12:51am UTC](https://forum.makecode.com/t/why-is-screen-fill-not-showing-the-correct-color/33506/4 "2025-02-01T00:51:43Z")

</div>

I see. Try making a post in the PXT category. They will know more than us in the Arcade category. Or maybe mods could edit your post to be in that category? Idk. Sometimes if you ask them it magically happens…
