DKGUNP6LG3DJ35VMHU42K3VJO5JJ5UVYI4PLM72HO5ZNAQ4P366AC
WQNKNUVS4HNF53TL26RO4CULUER3K4B4ZYTBCFB6NEKF2GYJPCCAC
YZOKY24YZN3DVMKWQSI3MBPR254G7PDHYOBV52CZU5BABBCXQKCQC
7B5SB3V7YC4HKFX6PIX6IHJ4U3BKYLD5EBMEY6O5FQ7YGN4VVI4AC
3JPFVDY52J7GVMQL5I5KJVKZGARIR43J5HMYWE5VN6GLNYUX3Y3QC
N7AJTLSWYZDDPB3JDCRGZVLGX7GCUMHYQB4OAKNETMDHENAZAJCQC
GHIHJCWBCGFZI4AG66L7WG4WKJ467DXFBRBNLT4ZULSN7ZVBJI6AC
PAOLWMH7TLJLNAWBJBWP7KB7YGDFUPASMTFU33KZ3QW5JXJMPXCAC
GROTV3H2V6BHU5CA7WSLVYDCWAR7GHUP5JV2QOGPLJ6N3553T4MAC
MT6IBX7SGLE26XIFZY53WYNHSJZMSDVDRJP3VYPXIQ4DKY75XVXAC
L6RIUKGLJZLAOKFGUDTZKBPP4HUBPEZAKHJEQHO34WFF62AB2ZIQC
KID2E3YKLHUFPHWYYGRQZTX73THWMAXQWPT5XZEJJO46BCQD27HQC
WQIQA2TNWNSNGKQC22XPTECAZEWG6PG5QWQECUVXDUQRSCV6RUZQC
MMCK5BQQST5NDI5R3VLY7ICBGNARTYG2FKKRPRIXQHXXGH2QO3PQC
DOR7S6M2PZ5FQ7TFGWIK7FUFUZENXKU4G42I5HQITODPBBEJB4YQC
X5EMQBC4BFNJOOHS2QMF4UB4QH6JKSALK6RXLK6B7SP6MNYSAP6QC
4RVKY4GPSLJ354NLVZDZFB7UFRMOTIC22NQIHYPEU6FKYLKBN75QC
}
#[derive(serde::Deserialize, Debug, Clone, Copy)]
struct TextColor(
#[serde(deserialize_with = "palette::serde::deserialize_with_optional_alpha")] palette::Srgba,
);
#[derive(serde::Deserialize, Debug, Clone)]
struct Text {
font_size: f32,
#[serde(default)]
text_dims: Option<glam::Vec2>,
text: String,
#[serde(default)]
position: Option<glam::Vec2>,
#[serde(default)]
scale: Option<f32>,
#[serde(default)]
color: Option<TextColor>,
#[serde(default)]
lines: Option<usize>,
let metrics = Metrics::new(32.0, 20.0);
let mut buffer = Buffer::new(&mut self.fonts, metrics);
{
let mut buffer = buffer.borrow_with(&mut self.fonts);
buffer.set_size(250.0, 25.0);
let attrs = Attrs::new().family(glyphon::Family::Name("Poiret One"));
buffer.set_text("Hello, game! 🦀\n", attrs, Shaping::Advanced);
buffer.shape_until_scroll();
}
let loc = glam::Vec2::new(32.0, 32.0);
let mut buffer2 = Buffer::new(&mut self.fonts, metrics);
{
let mut buffer2 = buffer2.borrow_with(&mut self.fonts);
buffer2.set_size(250.0, 25.0);
let attrs = Attrs::new()
.family(glyphon::Family::Name("Poiret One"))
.color(glyphon::Color::rgb(255, 255, 255));
buffer2.set_text("Hello, bloom! 🦀\n", attrs, Shaping::Advanced);
buffer2.shape_until_scroll();
}
let loc2 = glam::Vec2::new(32.0, 64.0);
vec![
(
buffer,
BufferMapper::new(self.convert_world_to_glyphon_world(loc), 1.0),
),
(
buffer2,
BufferMapper::new(self.convert_world_to_glyphon_world(loc2), 1.0),
),
]
let Ok(world_text) = assets.load::<TextList>("text_data.world") else {
let metrics = Metrics::new(32.0, 20.0);
let mut buffer = Buffer::new(&mut self.fonts, metrics);
{
let mut buffer = buffer.borrow_with(&mut self.fonts);
buffer.set_size(250.0, 25.0);
let attrs = Attrs::new().family(glyphon::Family::Name("Poiret One"));
buffer.set_text("Hello, game! 🦀\n", attrs, Shaping::Advanced);
buffer.shape_until_scroll();
}
let loc = glam::Vec2::new(32.0, 32.0);
let mut buffer2 = Buffer::new(&mut self.fonts, metrics);
{
let mut buffer2 = buffer2.borrow_with(&mut self.fonts);
buffer2.set_size(250.0, 25.0);
let attrs = Attrs::new()
.family(glyphon::Family::Name("Poiret One"))
.color(glyphon::Color::rgb(255, 255, 255));
buffer2.set_text("Y tho? 🦀\n", attrs, Shaping::Advanced);
buffer2.shape_until_scroll();
}
let loc2 = glam::Vec2::new(32.0, 64.0);
return vec![
(
buffer,
BufferMapper::new(self.convert_world_to_glyphon_world(loc), 1.0),
),
(
buffer2,
BufferMapper::new(self.convert_world_to_glyphon_world(loc2), 1.0),
),
];
};
world_text
.read()
.0
.iter()
.map(|text| {
let metrics = Metrics::new(text.font_size, 20.0);
let mut buffer = Buffer::new(&mut self.fonts, metrics);
{
let mut buffer = buffer.borrow_with(&mut self.fonts);
if let Some(text_dims) = text.text_dims {
buffer.set_size(text_dims.x, text_dims.y);
}
let attrs = Attrs::new().family(glyphon::Family::Name("Poiret One"));
buffer.set_text(
&text.text,
if let Some(color) = text.color {
let color: palette::Srgba<u8> = color.0.into_format();
attrs.color(glyphon::Color::rgba(
color.red,
color.green,
color.blue,
color.alpha,
))
} else {
attrs
},
Shaping::Advanced,
);
for line_idx in 0..text.lines.unwrap_or(1) {
buffer.line_shape(line_idx);
buffer.line_layout(line_idx);
}
}
(
buffer,
BufferMapper::new(
self.convert_world_to_glyphon_world(text.position.unwrap_or_default()),
text.scale.unwrap_or(1.0),
),
)
})
.collect()
let metrics = Metrics::new(32.0, 20.0);
let mut buffer = Buffer::new(&mut self.fonts, metrics);
{
let mut buffer = buffer.borrow_with(&mut self.fonts);
buffer.set_size(200.0, 25.0);
let attrs = Attrs::new().family(glyphon::Family::Name("Poiret One"));
buffer.set_text("Hello, Rust! 🦀\n", attrs, Shaping::Advanced);
buffer.shape_until_scroll();
}
vec![(buffer, BufferMapper::new((32.0, 32.0).into(), 1.0))]
let Ok(cam_text) = assets.load::<TextList>("text_data.camera") else {
let metrics = Metrics::new(32.0, 20.0);
let mut buffer = Buffer::new(&mut self.fonts, metrics);
{
let mut buffer = buffer.borrow_with(&mut self.fonts);
buffer.set_size(200.0, 25.0);
let attrs = Attrs::new().family(glyphon::Family::Name("Poiret One"));
buffer.set_text("Hello, Rust! 🦀\n", attrs, Shaping::Advanced);
buffer.shape_until_scroll();
}
return vec![(buffer, BufferMapper::new((32.0, 32.0).into(), 1.0))];
};
cam_text
.read()
.0
.iter()
.map(|text| {
let metrics = Metrics::new(text.font_size, 20.0);
let mut buffer = Buffer::new(&mut self.fonts, metrics);
{
let mut buffer = buffer.borrow_with(&mut self.fonts);
if let Some(text_dims) = text.text_dims {
buffer.set_size(text_dims.x, text_dims.y);
}
let attrs = Attrs::new().family(glyphon::Family::Name("Poiret One"));
buffer.set_text(
&text.text,
if let Some(color) = text.color {
let color: palette::Srgba<u8> = color.0.into_format();
attrs.color(glyphon::Color::rgba(
color.red,
color.green,
color.blue,
color.alpha,
))
} else {
attrs
},
Shaping::Advanced,
);
buffer.shape_until_scroll();
}
(
buffer,
BufferMapper::new(text.position.unwrap_or_default(), text.scale.unwrap_or(1.0)),
)
})
.collect()
assets_manager = { version = "0.11.2", features = ["hot-reloading", "embedded", "zip", "json", "toml", "flac", "wav", "jpeg", "png"] }
assets_manager = { version = "0.11.2", features = ["hot-reloading", "embedded", "zip", "json", "toml", "flac", "wav", "jpeg", "png", "ron"] }
name = "palette"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d38e6e5ca1612e2081cc31188f08c3cba630ce4ba44709a153f1a0f38d678f2"
dependencies = [
"approx",
"fast-srgb8",
"palette_derive",
"phf",
"serde",
]
[[package]]
name = "palette_derive"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e05d1c929301fee6830dafa764341118829b2535c216b0571e3821ecac5c885b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "phf"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
"phf_macros",
"phf_shared",
]
[[package]]
name = "phf_generator"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
dependencies = [
"phf_shared",
"rand",
]
[[package]]
name = "phf_macros"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
dependencies = [
"phf_generator",
"phf_shared",
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "phf_shared"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"
dependencies = [
"siphasher",
]
[[package]]