mirror of
https://github.com/lisk77/comet.git
synced 2025-12-12 09:08:49 +00:00
feat(renderer2d): added method to precompute text texture bounds
This commit is contained in:
parent
9312dc4444
commit
4915cbcbfe
1 changed files with 11 additions and 1 deletions
|
|
@ -4,9 +4,10 @@ use crate::{
|
||||||
render_pass::{universal_clear_execute, universal_load_execute, RenderPass},
|
render_pass::{universal_clear_execute, universal_load_execute, RenderPass},
|
||||||
renderer::Renderer,
|
renderer::Renderer,
|
||||||
};
|
};
|
||||||
use comet_colors::Color;
|
use comet_colors::{sRgba, Color};
|
||||||
use comet_ecs::{Component, Render, Render2D, Transform2D};
|
use comet_ecs::{Component, Render, Render2D, Transform2D};
|
||||||
use comet_log::*;
|
use comet_log::*;
|
||||||
|
use comet_math::v2;
|
||||||
use comet_resources::{
|
use comet_resources::{
|
||||||
font::Font, graphic_resource_manager::GraphicResourceManager, texture_atlas::*, Texture, Vertex,
|
font::Font, graphic_resource_manager::GraphicResourceManager, texture_atlas::*, Texture, Vertex,
|
||||||
};
|
};
|
||||||
|
|
@ -565,6 +566,15 @@ impl<'a> Renderer2D<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn precompute_text_bounds(&self, text: String, font: String, size: f32) -> v2 {
|
||||||
|
let mut bounds = v2::ZERO;
|
||||||
|
|
||||||
|
let _ =
|
||||||
|
self.add_text_to_buffers(text, font, size, v2::ZERO, wgpu::Color::WHITE, &mut bounds);
|
||||||
|
|
||||||
|
bounds
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add_text_to_buffers(
|
pub fn add_text_to_buffers(
|
||||||
&self,
|
&self,
|
||||||
text: String,
|
text: String,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue