Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

bevy_ninepatch weird gaps #1

Open
Atakku opened this issue Nov 26, 2021 · 0 comments
Open

bevy_ninepatch weird gaps #1

Atakku opened this issue Nov 26, 2021 · 0 comments

Comments

@Atakku
Copy link

Atakku commented Nov 26, 2021

I'm just starting out with bevy and testing things out, seems that the tiles have weird gaps when the final size is uneven.
Here is the code:

use bevy::prelude::*;
use bevy_ninepatch::{NinePatchBuilder, NinePatchBundle, NinePatchData, NinePatchPlugin};

fn main() {
  App::build()
    .add_plugins(DefaultPlugins)
    .add_plugin(NinePatchPlugin::<()>::default())
    .add_startup_system(setup.system())
    .run();
}

fn setup(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
    mut nine_patches: ResMut<Assets<NinePatchBuilder<()>>>,
) {
    let panel_texture_handle = asset_server.load("gui8.png");

    // load the 9-Patch as an assets and keep an `Handle<NinePatchBuilder<()>>`
    let nine_patch_handle = nine_patches.add(NinePatchBuilder::by_margins(32, 32, 32, 32));

    commands.spawn_bundle(
        // this component bundle will be detected by the plugin, and the 9-Patch UI element will be added as a child
        // of this entity
        NinePatchBundle {
            style: Style {
                margin: Rect::all(Val::Auto),
                justify_content: JustifyContent::Center,
                align_items: AlignItems::Center,
                size: Size::new(Val::Px(256.), Val::Px(257.)),
                ..Default::default()
            },
            nine_patch_data: NinePatchData {
                nine_patch: nine_patch_handle,
                texture: panel_texture_handle,
                ..Default::default()
            },
            ..Default::default()
        },
    );

    commands.spawn_bundle(UiCameraBundle::default());
}

Assets used:
gui8.png

Screenshot of the issue:
20211126194225

@mockersf mockersf transferred this issue from vleue/bevy_easings Jan 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant