# Translucent filled rectangle etc

**URL:** <https://discourse.libsdl.org/t/translucent-filled-rectangle-etc/26770>\
**Category:** SDL Development\
**Created:** [October 27, 2019, 6:38am UTC](https://discourse.libsdl.org/t/translucent-filled-rectangle-etc/26770 "2019-10-27T06:38:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joelcnz](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/joelcnz/32/3879_2.png) [@joelcnz](https://discourse.libsdl.org/u/joelcnz)\
**Post date:** [October 27, 2019, 6:38am UTC](https://discourse.libsdl.org/t/translucent-filled-rectangle-etc/26770/1 "2019-10-27T06:38:22Z")

</div>

Do I just draw, make a texture and use blending and alpha?

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [October 27, 2019, 5:20pm UTC](https://discourse.libsdl.org/t/translucent-filled-rectangle-etc/26770/2 "2019-10-27T17:20:37Z")

</div>

Drawing a ‘translucent filled rectangle’ can be achieved as follows. where `alpha` is set to the desired opacity:

```
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(renderer, r, g, b, alpha);
SDL_RenderFillRect(renderer, &rect);
```

---

<div class="post-metadata">

**Author:** ![joelcnz](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/joelcnz/32/3879_2.png) [@joelcnz](https://discourse.libsdl.org/u/joelcnz)\
**Post date:** [October 28, 2019, 12:42am UTC](https://discourse.libsdl.org/t/translucent-filled-rectangle-etc/26770/3 "2019-10-28T00:42:14Z")

</div>

> [@rtrussell](#):
>
> SDL\_SetRenderDrawBlendMode(renderer, SDL\_BLENDMODE\_BLEND);

Yay, that worked, thanks rtrussell. 🙂
