mawi1512

Best way to draw rectangle with border

Recommended Posts

Hi all,

I would like to know what's the most performant way to draw rectangles with borders. In my project I have to draw many such rectangles and they will change their width very often through different user actions. Actually I'm using NineSlicePlane, but maybe there is a other solutions with even better performance...

Thank you!

Share this post


Link to post
Share on other sites
On 1/31/2019 at 9:15 PM, bubamara said:

sprite with another slightly smaller sprite as it's child

I already had the idea, but somehow it feels like a workaround, not a native solution and I asked myself if there is no other native solution. But if the experts here in the forum also suggest it, then I'll take a closer look at it. :)

19 hours ago, xerver said:

Are you encountering a performance issue with the method you are using?

I can't answer that question with a clear yes or no. In my project the number of rectangles to draw depends on the users data model. And on large models there is a noticeable difference between normal sprite rect and a border rect with NineSlicePlane. Therefore my question how to get the difference smaller :).

Thank you for your fast answers...

Share this post


Link to post
Share on other sites

Sorry, I should have been clearer : it depends on your use case and Pixi version. For example if you are using Pixi 4.x and mixing up NineSlicePlane with Sprites, then above mentioned Sprite-Sprite approach should be noticeably faster. Pixi 5.x can batch mesh (NineSlice) with Sprite, thus making speed difference less visible.

On the other hand Pixi 4 seems to have better raw performance than v5, feel free to compare yourself : https://themoonrat.github.io/webgl-benchmark/

And when you have mentioned that you are updating them often, then it's another reason to try pure sprites approach. Anyway, would love to hear your conclusion if you find a time to compare :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.