Sitemap
CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

The Power of Nine-Patching in Godot

AKA: stretching UI without ugly distortions :)

3 min readSep 28, 2025

--

Ever tried resizing a UI panel and ended up with weirdly stretched corners? Using a NinePatchRect node can fix this by letting you define fixed corners and stretching just the “middle” of the texture — a great solution for your UI panels, buttons, and speech bubbles.

Press enter or click to view image in full size

To use this tool, the idea is the following:

  • Create a NinePatchRect node.
  • Set its Texture property to the image you want to nine-slice. Ideally, this image should thus have corners and a “middle” area that can be stretched (or tiled) properly, no matter what size and ratio the UI element is.
  • Use the properties in the Patch Margin section of the NinePatchRect node’s inspector to give Godot the size (in pixels) of the corners to keep as-is when nine-slicing.
Press enter or click to view image in full size

And well, that’s it! You can now create as many variations as you want with multiple NinePatchRect nodes, and you’ll see that no…

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Mina Pêcheux
Mina Pêcheux

Written by Mina Pêcheux

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)

Responses (1)