added more extensions
This commit is contained in:
21
extensions/fablabchemnitz/streaks/meta.json
Normal file
21
extensions/fablabchemnitz/streaks/meta.json
Normal file
@ -0,0 +1,21 @@
|
||||
[
|
||||
{
|
||||
"name": "Streaks",
|
||||
"id": "fablabchemnitz.de.streaks",
|
||||
"path": "streaks",
|
||||
"dependent_extensions": null,
|
||||
"original_name": "streaks",
|
||||
"original_id": "ca.sfu.AT.kurn.Streaks",
|
||||
"license": "GNU GPL v3",
|
||||
"license_url": "https://sourceforge.net/projects/inkscape-streaks/",
|
||||
"comment": "ported to Inkscape v1 by Mario Voigt",
|
||||
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/streaks",
|
||||
"fork_url": "https://sourceforge.net/projects/inkscape-streaks",
|
||||
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Streaks",
|
||||
"inkscape_gallery_url": null,
|
||||
"main_authors": [
|
||||
"sourceforge.net/andrew-kurn",
|
||||
"github.com/vmario89"
|
||||
]
|
||||
}
|
||||
]
|
42
extensions/fablabchemnitz/streaks/streaks.inx
Normal file
42
extensions/fablabchemnitz/streaks/streaks.inx
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Streaks</name>
|
||||
<id>fablabchemnitz.de.streaks</id>
|
||||
<param type="notebook" name="Nmain">
|
||||
<page name="top" gui-text="Color">
|
||||
<label appearance="header">Fills a box with a texture made of vertical line segments.</label>
|
||||
<param name="strokeColor" type="color" appearance="colorbutton" gui-text="Line color">255</param>
|
||||
<separator/>
|
||||
<param name="strokeWidth" type="int" gui-text="Line width (px)">2</param>
|
||||
</page>
|
||||
<page name="main" gui-text="Main">
|
||||
<param max="256" name="blur" type="int" gui-text="Blur">2</param>
|
||||
<param max="1000" name="linno" type="int" gui-text="# of columns">50</param>
|
||||
<param name="xrand" type="bool" gui-text="Lines randomized">true</param>
|
||||
<separator/>
|
||||
<param name="pagep" type="bool" gui-text="Default box to page size?">true</param>
|
||||
<param max="10000" name="cusx" type="int" gui-text="Custom size x">500</param>
|
||||
<param max="10000" name="cusy" type="int" gui-text="Custom size y">500</param>
|
||||
</page>
|
||||
<page name="vert" gui-text="Each column">
|
||||
<param min="1" max="256" name="segLen" type="int" gui-text="# of segments">8</param>
|
||||
<param name="yrand" type="bool" gui-text="Lengths randomized">true</param>
|
||||
<param name="dashp" type="bool" gui-text="Use dashes?">true</param>
|
||||
<param name="blankp" type="bool" gui-text="Use blanks?">true</param>
|
||||
<param name="dotp" type="bool" gui-text="Use dots?">true</param>
|
||||
<param max="1000" name="dots" type="int" gui-text="Dots per height">100</param>
|
||||
<label>This sets the size of a dot relative to the total height. Higher is shorter.</label>
|
||||
</page>
|
||||
</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="FabLab Chemnitz Shape Generators">
|
||||
<submenu name="Streaks And Blobs" />
|
||||
</submenu>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command location="inx" interpreter="python">streaks.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
157
extensions/fablabchemnitz/streaks/streaks.py
Normal file
157
extensions/fablabchemnitz/streaks/streaks.py
Normal file
@ -0,0 +1,157 @@
|
||||
#! /usr/bin/env python3
|
||||
import random
|
||||
rr = random.randint(1,10)
|
||||
import inkex
|
||||
from lxml import etree
|
||||
|
||||
class Streaks(inkex.EffectExtension):
|
||||
|
||||
def add_arguments(self, pars):
|
||||
pars.add_argument('--blur', type = int, default = 2)
|
||||
pars.add_argument('--linno', type = int, default = 50)
|
||||
pars.add_argument('--xrand', type = inkex.Boolean, default = True)
|
||||
pars.add_argument('--pagep', type = inkex.Boolean, default = True)
|
||||
pars.add_argument('--cusx', type = int, default = 500)
|
||||
pars.add_argument('--cusy', type = int, default = 500)
|
||||
pars.add_argument('--segLen', type = int, default = 8)
|
||||
pars.add_argument('--yrand', type = inkex.Boolean, default = True)
|
||||
pars.add_argument('--dashp', type = inkex.Boolean, default = True)
|
||||
pars.add_argument('--blankp', type = inkex.Boolean, default = True)
|
||||
pars.add_argument('--dotp', type = inkex.Boolean, default = True)
|
||||
pars.add_argument('--dots', type = int, default = 100)
|
||||
pars.add_argument('--strokeColor', default = 255)
|
||||
pars.add_argument('--strokeWidth', type = int, default = 2)
|
||||
pars.add_argument("--Nmain", default='title')
|
||||
|
||||
def effect(self):
|
||||
blur = int(self.options.blur)
|
||||
linno = int(self.options.linno)
|
||||
xrand = bool(self.options.xrand)
|
||||
pagep = bool(self.options.pagep)
|
||||
cusx = int(self.options.cusx)
|
||||
cusy = int(self.options.cusy)
|
||||
segLen = int(self.options.segLen)
|
||||
yrand = bool(self.options.yrand)
|
||||
dashp = bool(self.options.dashp)
|
||||
blankp = bool(self.options.blankp)
|
||||
dotp = bool(self.options.dotp)
|
||||
dots = int(self.options.dots)
|
||||
strokeColor = int(self.options.strokeColor)
|
||||
strokeWidth = int(self.options.strokeWidth)
|
||||
|
||||
# Get access to main SVG document element and get its dimensions.
|
||||
svg = self.document.getroot()
|
||||
|
||||
if pagep :
|
||||
try :
|
||||
width = self.svg.unittouu(svg.get('width'))
|
||||
height = self.svg.unittouu(svg.attrib['height'])
|
||||
except AttributeError :
|
||||
width = self.unittouu(svg.get('width'))
|
||||
height = self.unittouu(svg.attrib['height'])
|
||||
# inkex.errormsg("Page size %d %d" % (width, height))
|
||||
else :
|
||||
width = cusx
|
||||
height = cusy
|
||||
|
||||
|
||||
# Find defs node.
|
||||
for child in svg :
|
||||
if -1 != child.tag.find("defs") :
|
||||
break
|
||||
else:
|
||||
inkex.errormsg("No defs child found")
|
||||
defs = child
|
||||
|
||||
if blur :
|
||||
filter = etree.SubElement(defs, "filter")
|
||||
filter.set(inkex.addNS('collect', 'inkscape'), 'always')
|
||||
filname = self.svg.get_unique_id('filter')
|
||||
filter.set('id' , filname)
|
||||
|
||||
finfo = etree.SubElement(filter, 'feGaussianBlur')
|
||||
finfo.set(inkex.addNS('collect', 'inkscape'), 'always')
|
||||
finfo.set('stdDeviation', str(blur))
|
||||
|
||||
""" Debug
|
||||
for i in range(len(svg)) :
|
||||
k = svg[i].attrib
|
||||
for ky in k :
|
||||
inkex.errormsg(ky)
|
||||
|
||||
# Clean any old layers
|
||||
flag = False
|
||||
for i in range(len(svg)) :
|
||||
dic = svg[i].attrib
|
||||
for key in dic:
|
||||
if -1 != key.find("label") :
|
||||
if 'Streak Layer' == dic[key] :
|
||||
del svg[i]
|
||||
flag = True
|
||||
if flag :
|
||||
inkex.errormsg("Found old Streak layer")
|
||||
else:
|
||||
inkex.errormsg("Clean")
|
||||
"""
|
||||
# Create a new layer.
|
||||
layer = etree.SubElement(svg, 'g')
|
||||
layer.set(inkex.addNS('label', 'inkscape'), 'Streak Layer')
|
||||
layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer')
|
||||
|
||||
# Create path element
|
||||
path = etree.Element(inkex.addNS('path','svg'))
|
||||
|
||||
alpha = strokeColor & 255
|
||||
color = (strokeColor >> 8) & int('ffffff', 16)
|
||||
style = {
|
||||
'stroke' : '#%06X' % color,
|
||||
'stroke-width' : "{}px".format(strokeWidth),
|
||||
}
|
||||
#inkex.errormsg("Colour %s" % strokeColor)
|
||||
|
||||
if blur : style['filter'] = 'url(#' + filname +')'
|
||||
|
||||
|
||||
path.set('style', str(inkex.Style(style)))
|
||||
|
||||
pathstring = ''
|
||||
seglim = int(height / segLen)
|
||||
ditlen = int(height / dots)
|
||||
|
||||
xco = 0
|
||||
while xco < width :
|
||||
y = 0
|
||||
flag = random.randint(0, 2)
|
||||
while y < height :
|
||||
if yrand :
|
||||
yinc = random.randint(1, seglim)
|
||||
else :
|
||||
yinc = seglim
|
||||
if flag == 1 and dashp: #Draw dash
|
||||
pathstring += ' M '+str(xco)+','+str(y)+' L '+str(xco)+','+str(min(y + yinc, height))
|
||||
y += yinc + ditlen
|
||||
elif flag == 2 and dotp: #Draw dots
|
||||
ylim = min(y + yinc, height)
|
||||
while y < ylim :
|
||||
pathstring += ' M '+str(xco)+','+str(y)+' L '+str(xco)+','+str(min(y + ditlen, height))
|
||||
y += 2*ditlen
|
||||
elif flag == 0 and blankp :
|
||||
y += yinc #Adding blank space
|
||||
elif not (dashp or dotp or blankp) : #Squiggle if user turns them off
|
||||
sdit = str(2*ditlen)+' '
|
||||
pathstring += ' M '+str(xco)+','+str(y)+' q '+ 2*sdit + '0 ' +sdit
|
||||
for i in range(int(height/(2*ditlen))) :
|
||||
pathstring += 't 0 '+sdit
|
||||
y = height
|
||||
flag = (flag + 1)%3
|
||||
if xrand :
|
||||
xco += random.randint(0, int(2 * width / linno))
|
||||
else :
|
||||
xco += width / linno
|
||||
path.set('d', pathstring)
|
||||
|
||||
# Connect elements together.
|
||||
layer.append(path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Streaks().run()
|
Reference in New Issue
Block a user