Layer opacity (#312)

Closes #187

* Add layer opacity input

* Improve Rust code cleanliness
This commit is contained in:
Keavon Chambers
2021-07-27 23:15:23 -07:00
parent 12fc330952
commit 0cdd1762b8
9 changed files with 86 additions and 18 deletions

View File

@@ -213,7 +213,7 @@ pub fn reorder_selected_layers(delta: i32) -> Result<(), JsValue> {
.map_err(convert_error)
}
/// Set the blend mode of the selected layers
/// Set the blend mode for the selected layers
#[wasm_bindgen]
pub fn set_blend_mode_for_selected_layers(blend_mode_svg_style_name: String) -> Result<(), JsValue> {
let blend_mode = match blend_mode_svg_style_name.as_str() {
@@ -239,6 +239,17 @@ pub fn set_blend_mode_for_selected_layers(blend_mode_svg_style_name: String) ->
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::SetBlendModeForSelectedLayers(blend_mode)).map_err(convert_error))
}
/// Set the opacity for the selected layers
#[wasm_bindgen]
pub fn set_opacity_for_selected_layers(opacity_percent: f64) -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| {
editor
.borrow_mut()
.handle_message(DocumentMessage::SetOpacityForSelectedLayers(opacity_percent / 100.))
.map_err(convert_error)
})
}
/// Export the document
#[wasm_bindgen]
pub fn export_document() -> Result<(), JsValue> {