forked from 1b-agent/opencadstudio-upstream
Raster images: transparency off draws pixels opaque; TRANSPARENCY command
An image's transparency flag decides whether transparent pixels show what is behind the image or draw in their stored colour: the image pass and PDF plots now follow it (it was ignored, so every PNG alpha showed through). TRANSPARENCY selects images and asks for the mode, defaulting to the first image's current one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
801882314f
commit
5ca7becd97
30 files changed
+237
-6
No files matched your search
@@ -929,6 +929,55 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TRANSPARENCY — raster images show transparent pixels (ON) or
|
||||
// draw every pixel in its colour (OFF).
|
||||
"TRANSPARENCY" => {
|
||||
let c = crate::modules::insert::image_transparency::TransparencyCommand::new();
|
||||
self.command_line.push_info(&c.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
"TRANSPARENCY MODE" | "TRANSPARENCY ON" | "TRANSPARENCY OFF" => {
|
||||
use codec::entities::ImageDisplayFlags;
|
||||
let images: Vec<(codec::Handle, bool)> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.filter(|(handle, _)| !self.tabs[i].scene.is_layer_locked(*handle))
|
||||
.filter_map(|(handle, _)| match self.tabs[i].scene.document.get_entity(*handle) {
|
||||
Some(codec::EntityType::RasterImage(image)) => {
|
||||
Some((*handle, image.flags.contains(ImageDisplayFlags::TRANSPARENCY_ON)))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let Some(&(_, first_on)) = images.first() else {
|
||||
return Some(Task::none());
|
||||
};
|
||||
let handles: Vec<codec::Handle> = images.iter().map(|(handle, _)| *handle).collect();
|
||||
if cmd == "TRANSPARENCY MODE" {
|
||||
let c = crate::modules::insert::image_transparency::TransparencyCommand::mode(
|
||||
handles, first_on,
|
||||
);
|
||||
self.command_line.push_info(&c.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
} else {
|
||||
let on = cmd == "TRANSPARENCY ON";
|
||||
self.push_undo_snapshot(i, "TRANSPARENCY");
|
||||
for handle in &handles {
|
||||
if let Some(codec::EntityType::RasterImage(image)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(*handle)
|
||||
{
|
||||
image.flags.set(ImageDisplayFlags::TRANSPARENCY_ON, on);
|
||||
}
|
||||
}
|
||||
let changes: Vec<_> = handles
|
||||
.iter()
|
||||
.map(|handle| (*handle, crate::scene::ChangeKind::Modified))
|
||||
.collect();
|
||||
self.tabs[i].scene.bump_entities(&changes);
|
||||
self.tabs[i].dirty = true;
|
||||
}
|
||||
}
|
||||
// UNDERLAY — edit properties of selected PDF/DWF/DGN underlay entities.
|
||||
// Usage:
|
||||
// UNDERLAY FADE <0-80>
|
||||
|
||||
@@ -714,6 +714,7 @@ inventory::submit!(crate::command::CommandRegistration {
|
||||
"IM",
|
||||
"IMAGE",
|
||||
"IMAGEATTACH",
|
||||
"TRANSPARENCY",
|
||||
"IMAGEEMBED",
|
||||
"IMPORTOBJ",
|
||||
"ISOLATEOBJECTS",
|
||||
|
||||
Reference in new issue
Block a user