TextureRect
Asked Answered
S

13

0

How to Round TextureRect in Godot 4.1.3 ?

Setsukosett answered 16/11, 2023 at 18:2 Comment(0)
P
0

You could use a texture that contains a round shape inside a transparent background.

(That's a screenshot, not the actual image with a transparent background.)

Pringle answered 16/11, 2023 at 18:38 Comment(0)
S
0

Pringle How to use it?

Setsukosett answered 16/11, 2023 at 18:42 Comment(0)
P
0

Place it in the Godot project folder, and drag it from the FileSystem dock into the TextureRect's texture field in the Inspector. You can also load the texture using code.

Pringle answered 16/11, 2023 at 18:51 Comment(0)
S
0

Pringle Maybe I put it wrong , I need to round the edges of a square picture ! How to do it?

Setsukosett answered 16/11, 2023 at 19:9 Comment(0)
S
0

Pringle Example

Setsukosett answered 16/11, 2023 at 19:11 Comment(0)
P
0

Use an application such as Gimp or Inkscape to round the corners.

As far as I know, Godot can't do that, unless someone has created an addon that does it.

Pringle answered 16/11, 2023 at 19:22 Comment(0)
S
0

Pringle It can't be done in Godot ?

Setsukosett answered 16/11, 2023 at 19:28 Comment(0)
C
0

Setsukosett You can do it with a shader, but it's much easier to just cut it in an image editing app.

Concavity answered 16/11, 2023 at 19:30 Comment(0)
S
0

A PanelContainer can have round corners when creating a theme for it so earlier I tried using one with a texture rect as its content but I found no way to clip the image. Maybe one could use a shader for that but I am no shader expert.

Symphonize answered 16/11, 2023 at 19:42 Comment(0)
P
0

A styleboxflat (like with panelcontainer) can have its corners rounded, you can then use clip in canvasitem to confine a children node to it. It's that simple!
You NEED themes if you use UI, it's the way of working in godot and it's really good, so look into it.

Pyrrolidine answered 17/11, 2023 at 8:9 Comment(0)
T
0

Setsukosett
Use vector drawing application like Inkscape which is free or Adobe illustrator. It will maintain shape irrespective of resolution

Tollefson answered 17/11, 2023 at 16:48 Comment(0)
S
0

You can do this by adding the TextureRect as a child of a PanelContainer.
Add a StyleBoxFlat to the PanelContainer in "Theme overrides -> Styles -> Panel". Then set the corner radius to whatever values you like best.
Then, in PanelContainer go to "Visibility -> Clip children" and set it to "Clip only" or "Clip + Draw".

Sentimentalism answered 6/12, 2023 at 15:17 Comment(0)
P
0

Sentimentalism Thanks!

Pearman answered 18/1 at 10:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.