Best method to implement 9 slice?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Posts: 7
Joined: Wed Dec 12, 2018 1:43 pm

Best method to implement 9 slice?

Post by ShoesForClues » Fri Sep 20, 2019 3:44 am

I'm currently working on a GUI framework and I'm trying to implement 9 slice in order to properly scale windows and borders. What's the best way to go around this? I'm aware that you could use quads to only draw certain parts of an image, but is that more efficient than just using setScissor?

Party member
Posts: 118
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: Best method to implement 9 slice?

Post by Nelvin » Fri Sep 20, 2019 6:26 am

It's more efficient as changing the scissorrect will stop batching, so you'll create 9 draw calls. Also using scissors will be more complicated to implement as scissors are in screen coordinates, i.e. pixels, so you'd have to do more transformation work on your coordinates (in case you use any scaling while drawing but given the huge difference of monitor resolutions this is highly expected).

Also, if a 9 slice doesn't change often, you may add all the 9 quads manually into a spritebatch and only change it if you required (or create a mesh).

User avatar
Posts: 48
Joined: Thu Apr 04, 2019 3:32 pm

Re: Best method to implement 9 slice?

Post by CrimsonGuy » Fri Sep 20, 2019 6:51 pm ... ce#p227190

Found a kinda recent thread about this question.

Posts: 1
Joined: Thu Oct 24, 2019 12:16 am

Re: Best method to implement 9 slice?

Post by elneiew » Thu Oct 24, 2019 12:23 am

Finally a good explanation of what that enumtype does.
I’ve been waiting a long time to know how it works.
(Has no information on the wiki, except the tiny bit I added, which lacks about everything related to this)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 40 guests