quick hacky fix for save vis/vis to res

This commit is contained in:
tim h 2023-01-31 18:02:14 -06:00
parent 04a3cfdb71
commit a0e7608d06
2 changed files with 31 additions and 7 deletions

View file

@ -441,7 +441,7 @@
src="js/ui/tool/colorbrush.js?v=46011ee"
type="text/javascript"></script>
<script
src="js/ui/tool/select.js?v=63fe672"
src="js/ui/tool/select.js?v=39911b2"
type="text/javascript"></script>
<script src="js/ui/tool/stamp.js?v=d89b15d" type="text/javascript"></script>
<script

View file

@ -735,9 +735,21 @@ const selectTransformTool = () =>
saveVisibleSelectionButton.textContent = "Save Vis.";
saveVisibleSelectionButton.title = "Saves Visible Selection";
saveVisibleSelectionButton.onclick = () => {
const canvas = uil.getVisible(state.selected, {
categories: ["image", "user", "select-display"],
});
const canvas = uil.getVisible(
{
x:
state._selected._position.x -
state._selected.canvas.width / 2,
y:
state._selected._position.y -
state._selected.canvas.height / 2,
w: state._selected.canvas.width,
h: state._selected.canvas.height,
},
{
categories: ["image", "user", "select-display"],
}
);
downloadCanvas({
cropToContent: false,
canvas,
@ -751,9 +763,21 @@ const selectTransformTool = () =>
createVisibleResourceButton.title =
"Saves Visible Selection as a Resource";
createVisibleResourceButton.onclick = () => {
const canvas = uil.getVisible(state.selected, {
categories: ["image", "user", "select-display"],
});
const canvas = uil.getVisible(
{
x:
state._selected._position.x -
state._selected.canvas.width / 2,
y:
state._selected._position.y -
state._selected.canvas.height / 2,
w: state._selected.canvas.width,
h: state._selected.canvas.height,
},
{
categories: ["image", "user", "select-display"],
}
);
const image = document.createElement("img");
image.src = canvas.toDataURL();
image.onload = () => {