added random delete
This commit is contained in:
parent
47e0ab50a5
commit
859b4f46c6
20
extensions/fablabchemnitz/random_delete/meta.json
Normal file
20
extensions/fablabchemnitz/random_delete/meta.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"name": "Random Delete",
|
||||
"id": "fablabchemnitz.de.random_delete",
|
||||
"path": "random_delete",
|
||||
"dependent_extensions": null,
|
||||
"original_name": "Random Delete",
|
||||
"original_id": "fablabchemnitz.de.random_delete",
|
||||
"license": "GNU GPL v3",
|
||||
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/LICENSE",
|
||||
"comment": "Written by Mario Voigt",
|
||||
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/random_delete",
|
||||
"fork_url": null,
|
||||
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Random+Delete",
|
||||
"inkscape_gallery_url": null,
|
||||
"main_authors": [
|
||||
"github.com/vmario89"
|
||||
]
|
||||
}
|
||||
]
|
16
extensions/fablabchemnitz/random_delete/random_delete.inx
Normal file
16
extensions/fablabchemnitz/random_delete/random_delete.inx
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Random Delete</name>
|
||||
<id>fablabchemnitz.de.random_delete</id>
|
||||
<param name="prob" type="float" gui-text="Probability of deletion (%):" min="0.0" max="100.0">100.0</param>
|
||||
<param name="title" type="description">This extension allows to delete with a certain probability each of the selected objects.</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="Render" />
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command location="inx" interpreter="python">random_delete.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
21
extensions/fablabchemnitz/random_delete/random_delete.py
Normal file
21
extensions/fablabchemnitz/random_delete/random_delete.py
Normal file
@ -0,0 +1,21 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import random
|
||||
import inkex
|
||||
|
||||
class RandomDelete(inkex.Effect):
|
||||
|
||||
def add_arguments(self, pars):
|
||||
pars.add_argument("--prob", type=float, default=50, help="Probability of deletion")
|
||||
|
||||
def effect(self):
|
||||
if len(self.svg.selected) > 0:
|
||||
for element in self.svg.selection.values():
|
||||
if random.random() < self.options.prob/100:
|
||||
element.delete()
|
||||
else:
|
||||
self.msg('Please select some paths first.')
|
||||
return
|
||||
|
||||
if __name__ == '__main__':
|
||||
RandomDelete().run()
|
Reference in New Issue
Block a user