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
ShoesForClues
Prole
Posts: 15
Joined: Wed Dec 12, 2018 1:43 pm

Best method to implement 9 slice?

Post by ShoesForClues »

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?
Nelvin
Party member
Posts: 124
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: Best method to implement 9 slice?

Post by Nelvin »

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
CrimsonGuy
Prole
Posts: 48
Joined: Thu Apr 04, 2019 3:32 pm

Re: Best method to implement 9 slice?

Post by CrimsonGuy »

https://love2d.org/forums/viewtopic.php ... ce#p227190

Found a kinda recent thread about this question.
elneiew
Prole
Posts: 1
Joined: Thu Oct 24, 2019 12:16 am

Re: Best method to implement 9 slice?

Post by elneiew »

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: Google [Bot] and 2 guests