Skip to content

Commit 6ab0d02

Browse files
committed
#179. Add canvas save script gen.
1 parent 94b5059 commit 6ab0d02

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<scriptGenerator>
2+
<name>Сохранить рисунок</name>
3+
<description>Сохранить нарисованное изображение canvas в файл</description>
4+
<context>FormEditor.objectItem</context>
5+
6+
<source syntax="php"><![CDATA[
7+
// Задаем путь к сохраняемой картинке ...
8+
$filename = 'путь к jpg, png, gif';
9+
10+
// Создаем папку для файла, если ее нет ...
11+
fs::ensureParent($filename);
12+
13+
// Сохраняем изображение в файл.
14+
$this->#object.id#->save($filename, fs::ext($filename));
15+
]]></source>
16+
</scriptGenerator>

develnext/src/ide/formats/form/elements/CanvasFormElement.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public function getScriptGenerators()
9090
return [
9191
new IdeLibraryScriptGeneratorResource('res://.dn/bundle/uiDesktop/scriptgen/DrawLineCanvasScriptGen'),
9292
new IdeLibraryScriptGeneratorResource('res://.dn/bundle/uiDesktop/scriptgen/DrawSVGCanvasScriptGen'),
93+
new IdeLibraryScriptGeneratorResource('res://.dn/bundle/uiDesktop/scriptgen/SaveImageToFileCanvasScriptGen'),
9394
];
9495
}
9596
}

0 commit comments

Comments
 (0)