MCPcopy Create free account
hub / github.com/PerroEngine/Perro / apply_viewport_canvas

Function apply_viewport_canvas

perro_editor/res/scripts/ui/editor_ui.rs:4358–4421  ·  view source on GitHub ↗
(ctx: &mut ScriptContext<'_, API>)

Source from the content-addressed store, hash-verified

4356 fill: &str,
4357 stroke: &str,
4358 radius: f32,
4359) {
4360 let Some(fill) = Color::from_hex(fill) else {
4361 return;
4362 };
4363 let Some(stroke) = Color::from_hex(stroke) else {
4364 return;
4365 };
4366 if let Some(id) = find_named(ctx, name) {
4367 let _ = with_node_mut!(ctx.run, UiPanel, id, |node| {
4368 node.style.fill = fill;
4369 node.style.stroke = stroke;
4370 node.style.stroke_width = 1.0;
4371 node.style.set_corner_radius(radius);
4372 });
4373 }
4374}
4375
4376pub fn set_color_picker_value<API: ScriptAPI + ?Sized>(
4377 ctx: &mut ScriptContext<'_, API>,
4378 name: &str,
4379 fill: &str,
4380) {
4381 let Some(color) = Color::from_hex(fill) else {
4382 return;
4383 };
4384 if let Some(id) = find_named(ctx, name) {
4385 let _ = with_node_mut!(ctx.run, UiColorPicker, id, |node| {
4386 node.color = color;
4387 });
4388 }
4389}
4390
4391pub fn read_color_picker_value<API: ScriptAPI + ?Sized>(
4392 ctx: &mut ScriptContext<'_, API>,
4393 name: &str,
4394) -> Option<String> {
4395 let id = find_named(ctx, name)?;
4396 let [r, g, b, a] = with_node!(ctx.run, UiColorPicker, id, |node| node.color.to_rgba()).unwrap_or_default();
4397 Some(format!(
4398 "({}, {}, {}, {})",
4399 format_compact_f32(r),
4400 format_compact_f32(g),
4401 format_compact_f32(b),
4402 format_compact_f32(a)
4403 ))
4404}
4405
4406pub fn set_image_tint<API: ScriptAPI + ?Sized>(
4407 ctx: &mut ScriptContext<'_, API>,
4408 name: &str,
4409 tint: &str,
4410) {
4411 let Some(color) = Color::from_hex(tint) else {
4412 return;
4413 };
4414 if let Some(id) = find_named(ctx, name) {
4415 let _ = with_node_mut!(ctx.run, UiImage, id, |node| {

Callers 5

update_freecam_2dFunction · 0.85
update_ui_canvasFunction · 0.85
frame_selected_nodeFunction · 0.85
apply_viewport_modeFunction · 0.85

Calls 9

set_panel_displayFunction · 0.85
viewport_window_aspectFunction · 0.85
ui_canvas_size_ratioFunction · 0.85
set_ui_center_sizeFunction · 0.85
set_canvas_lineFunction · 0.85
wrap_grid_offsetFunction · 0.85
clampMethod · 0.45

Tested by

no test coverage detected