(ctx: &mut ScriptContext<'_, API>)
| 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 | |
| 4376 | pub 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 | |
| 4391 | pub 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 | |
| 4406 | pub 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| { |
no test coverage detected