Add files via upload

Creation of SVGs from DockWidget ist working now. Adding aditional SVGs for more diversity.
This commit is contained in:
Ananke 2022-07-18 20:12:50 +02:00 committed by GitHub
parent d13ab3b349
commit 512af67ff8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 354 additions and 89 deletions

View file

@ -1,6 +1,11 @@
from krita import * from krita import *
from textblob import TextBlob
from textblob_de import TextBlobDE
import re
from html.parser import HTMLParser from html.parser import HTMLParser
import urllib.request import urllib.request
from wordart.svg_vorlagen import *
# define class HTML-Parser # define class HTML-Parser
class MyHTMLParser(HTMLParser): class MyHTMLParser(HTMLParser):
@ -22,6 +27,7 @@ class MyHTMLParser(HTMLParser):
if self.capture: if self.capture:
self.data.append(data) self.data.append(data)
# define object/class for analysis # define object/class for analysis
class textforart: class textforart:
@ -104,3 +110,61 @@ def create_svg(svg):
layer = doc.createVectorLayer('ColorSVG') layer = doc.createVectorLayer('ColorSVG')
layer.setName('ColorSVG') layer.setName('ColorSVG')
add_svg(svg) add_svg(svg)
def makeart(content, parser):
parser.feed(urllib.request.urlopen(content).read().decode())
linkdata = parser.data
if linkdata is not None:
# language
language = ''
# filtering parsed text
text = ""
for phrases in linkdata:
phrases = phrases.rstrip("\n\r+0-9[]()+")
# skip unwanted characters
text = text + phrases
# create textblob
blob = TextBlob(text)
# language?
for w in blob.words:
if re.match(r"and", w):
language = 'en'
elif re.match(r"und", w):
language = 'de'
if language == 'de':
blob = TextBlobDE(text)
sentence_lens = []
commas = []
polarity = []
# print polarity of sentences
for sentence in blob.sentences:
# length of sentences
sentence_lens.append(len(sentence))
# number of commas
commas.append(len(re.findall(',', str(sentence))))
# polarity
polarity.append(sentence.sentiment.polarity)
# init new textforart object
art = textforart(language, sentence_lens, blob.sentences, commas, polarity)
# make art out of object
# fill color:#000000 # stroke color:#000000
stroke = "rgb(" + str(round(125*(1/art.mean_number_commas))) + ", " + str(round(125 - art.min_sentences_polarity)) + ", " + str(round(125 - art.max_sentences_polarity)) + ")"
fill = "rgb(" + str(round(125*(1/art.mean_number_commas))) + ", " + str(round(125 - art.min_sentences_polarity)) + ", " + str(round(125 - art.max_sentences_polarity)) + ")"
# define with of svg
heigh = 700- (10*art.mean_sentences_polarity)
width = 700*art.mean_number_commas
svg = design_svg(stroke, fill, heigh, width)
create_svg(svg)

View file

@ -9,7 +9,7 @@ import re
from krita import * from krita import *
import sip import sip
# svg # svg sight
def design_svg(strokecolor, fillcolor, width, height): def design_svg(strokecolor, fillcolor, width, height):
trans = str(((800 - height)/2) - 80) trans = str(((800 - height)/2) - 80)
#print (trans) #print (trans)
@ -19,7 +19,6 @@ def design_svg(strokecolor, fillcolor, width, height):
<svg version="1.1" id="Capa_1" x="0px" y="0px" <svg version="1.1" id="Capa_1" x="0px" y="0px"
width="{width}" height="{height}" viewBox="0 0 302.623 302.623" stroke="{strokecolor}" fill="{fillcolor}" style="enable-background:new 0 0 302.623 302.623;" width="{width}" height="{height}" viewBox="0 0 302.623 302.623" stroke="{strokecolor}" fill="{fillcolor}" style="enable-background:new 0 0 302.623 302.623;"
xml:space="preserve"> xml:space="preserve">
<g> <g>
<g> <g>
<path transform="translate(20, {trans})" d="M148.185,78.801c-88.048,0-144.647,69.607-147.013,72.579c-1.682,2.114-1.54,5.14,0.334,7.076 <path transform="translate(20, {trans})" d="M148.185,78.801c-88.048,0-144.647,69.607-147.013,72.579c-1.682,2.114-1.54,5.14,0.334,7.076
@ -33,3 +32,240 @@ def design_svg(strokecolor, fillcolor, width, height):
</g> </g>
</svg>'''.encode('utf-8') </svg>'''.encode('utf-8')
return(svg) return(svg)
# svg hearing
def design_svg2(strokecolor, fillcolor, width, height):
trans = str(((800 - height)/2) - 80)
svg = f'''<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="{width}" height="{height}" viewBox="0 0 1280.000000 1064.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,1064.000000) scale(0.100000,-0.100000)" stroke="{strokecolor}" fill="{fillcolor}">
<path transform="translate(20, {trans})" d="M6120 10634 c-25 -2 -108 -8 -185 -14 -683 -53 -1419 -249 -2154
-571 -162 -71 -534 -255 -665 -329 -235 -132 -434 -281 -639 -480 -266 -257
-478 -542 -627 -841 -111 -225 -174 -408 -222 -649 l-23 -115 -3 -3592 -2
-3593 420 0 420 0 0 3529 c0 3135 2 3538 15 3610 92 483 542 1063 1119 1442
192 127 333 193 720 339 1282 481 2244 557 3381 265 425 -109 1073 -341 1346
-481 183 -94 422 -266 599 -429 389 -359 657 -779 725 -1136 13 -72 15 -475
15 -3610 l0 -3529 420 0 420 0 -2 3593 -3 3592 -23 115 c-48 241 -111 424
-222 649 -227 457 -623 902 -1066 1199 -126 84 -273 166 -529 292 -836 412
-1607 642 -2427 725 -143 15 -704 28 -808 19z"/>
<path d="M2712 6148 c-73 -28 -153 -109 -181 -183 l-21 -56 2 -2837 3 -2837
27 -50 c35 -68 92 -122 158 -154 l55 -26 315 0 315 0 55 26 c66 32 123 86 158
154 l27 50 6 1445 c4 1003 9 1469 17 1525 22 156 20 151 50 153 46 3 54 -10
63 -104 11 -119 29 -630 29 -832 l0 -162 34 0 c19 0 37 3 40 8 11 19 36 170
46 278 6 65 14 226 19 357 5 153 12 242 20 250 8 8 11 2 11 -24 0 -36 18 -79
21 -49 3 29 18 -75 18 -128 1 -33 5 -51 11 -47 5 3 10 31 10 61 0 32 4 53 9
49 13 -7 21 53 29 210 l7 130 78 1 c51 1 80 -2 82 -10 1 -6 8 -47 13 -91 19
-142 51 -251 53 -179 2 60 16 -17 23 -126 14 -221 38 -455 47 -465 5 -5 9 -1
9 12 0 27 20 83 30 83 4 0 11 -11 14 -25 7 -26 26 -35 26 -12 0 6 4 50 9 97 5
47 12 123 16 170 6 96 42 445 51 503 3 20 11 37 19 37 17 0 25 -55 25 -190 0
-110 12 -301 26 -403 7 -55 22 -57 40 -6 10 30 12 31 15 11 6 -32 23 -32 27 1
4 30 18 36 24 10 6 -25 16 77 24 230 8 167 22 168 39 2 8 -70 24 -172 32 -199
13 -46 24 22 34 221 12 236 16 276 30 268 5 -4 9 5 9 19 0 15 8 30 19 36 23
12 91 13 109 1 7 -4 18 -40 24 -80 11 -68 28 -97 28 -47 0 40 12 86 21 80 5
-3 9 -24 10 -47 0 -31 3 -37 8 -22 5 12 12 -28 20 -110 19 -204 31 -292 57
-402 13 -55 27 -127 30 -158 4 -31 10 -52 14 -48 5 4 13 78 20 163 16 219 27
292 46 334 15 30 34 48 34 32 0 -3 5 -38 10 -78 6 -40 17 -142 25 -227 8 -84
16 -156 19 -158 9 -9 15 36 41 297 29 290 32 310 45 290 13 -22 19 -10 25 56
11 111 15 124 34 124 17 0 20 -12 25 -117 4 -65 11 -196 16 -290 6 -95 10
-187 10 -204 0 -52 17 -23 25 43 l8 63 10 -45 c9 -42 10 -44 19 -20 5 14 14
115 19 225 6 110 12 232 15 272 6 72 6 72 38 79 18 3 68 4 111 2 78 -3 79 -3
87 -33 4 -16 14 -35 22 -41 16 -11 29 -75 47 -236 11 -101 19 -123 34 -98 10
17 25 1 25 -28 0 -42 11 -72 26 -72 12 0 23 -29 39 -108 5 -26 10 -31 20 -22
7 6 16 23 20 37 8 35 45 83 45 59 0 -24 17 -19 24 7 10 38 26 -1 26 -67 0 -37
4 -56 9 -50 9 8 31 436 31 586 0 51 2 58 20 58 15 0 20 -7 21 -27 2 -102 28
-316 40 -327 5 -6 9 3 9 25 0 88 29 154 31 72 1 -21 4 -49 8 -63 7 -23 8 -21
14 15 3 22 9 101 13 177 l6 136 89 0 c49 0 91 -4 94 -8 3 -5 12 -7 19 -4 13 5
17 -30 32 -316 7 -126 9 -136 28 -121 19 16 26 -6 33 -96 3 -40 9 -70 13 -68
4 2 13 60 19 127 7 68 19 132 26 143 7 11 18 58 24 105 12 88 26 121 35 79 11
-54 16 -103 31 -291 8 -108 22 -229 30 -269 9 -40 18 -142 22 -226 3 -84 10
-153 15 -153 4 0 8 6 8 13 0 33 20 339 26 389 4 40 10 55 18 52 16 -6 22 44
36 295 5 96 11 176 13 178 2 1 9 -59 15 -135 6 -75 18 -162 27 -192 8 -30 15
-69 15 -87 0 -51 18 -48 24 4 3 27 8 129 11 228 5 122 11 190 21 211 7 18 17
56 22 85 l7 54 112 0 c61 0 115 -4 120 -8 4 -5 10 -44 12 -88 1 -43 7 -79 12
-79 5 0 9 8 9 17 0 11 3 14 10 7 11 -11 24 -163 39 -464 10 -184 16 -230 31
-230 13 0 20 45 35 223 14 179 54 539 59 544 2 2 5 -41 8 -96 3 -58 10 -107
17 -115 15 -18 40 -298 42 -471 0 -66 4 -131 8 -145 7 -24 8 -23 14 10 3 19
11 82 17 140 7 58 13 106 15 108 2 2 7 -12 10 -32 4 -20 11 -36 15 -36 13 0
18 49 32 269 12 202 21 245 39 178 4 -15 15 -93 24 -174 20 -172 23 -185 35
-162 25 44 55 243 78 519 l7 85 109 3 c60 1 113 -1 118 -6 4 -4 17 -120 29
-258 42 -524 52 -572 75 -364 8 82 19 105 28 62 8 -32 52 -70 66 -55 5 4 15
42 23 83 l15 75 2 -70 c2 -125 16 -263 25 -254 2 2 8 49 15 104 16 132 26 146
34 49 4 -43 10 -99 13 -124 6 -44 6 -44 15 -15 4 17 13 164 20 328 6 163 15
297 19 297 4 0 10 -42 13 -92 14 -203 30 -354 38 -378 l10 -25 12 25 c23 44
44 159 66 355 30 272 25 252 61 259 40 8 157 8 196 0 l30 -6 7 -166 c4 -92 11
-223 17 -292 9 -107 13 -128 31 -143 21 -17 22 -17 40 0 20 21 30 72 50 258
11 104 14 -68 18 -1320 l5 -1440 28 -56 c32 -66 99 -132 165 -162 45 -21 60
-22 367 -22 314 0 321 0 366 23 75 37 125 87 161 160 l33 67 0 2830 0 2830
-29 63 c-36 78 -105 143 -183 172 -54 20 -72 21 -367 18 l-311 -3 -50 -27
c-65 -34 -128 -100 -157 -163 l-23 -50 -5 -1230 c-3 -676 -9 -1219 -13 -1205
-4 14 -12 93 -17 175 -10 158 -18 215 -30 215 -9 0 -30 -134 -30 -190 0 -45
-10 -51 -25 -17 -6 12 -17 21 -26 19 -29 -4 -38 22 -49 153 -6 72 -15 153 -20
180 -5 28 -14 106 -20 175 -19 229 -21 245 -27 279 -8 48 -19 21 -27 -69 -16
-179 -67 -645 -71 -649 -3 -2 -5 8 -5 22 0 39 -17 33 -24 -8 -4 -20 -13 -35
-21 -35 -9 0 -16 -16 -19 -42 -5 -35 -26 -303 -26 -330 0 -5 -24 -8 -53 -8
l-54 0 -11 123 c-15 148 -54 397 -63 397 -8 0 -15 -73 -30 -317 l-12 -203 -42
0 -41 0 -17 98 c-9 53 -21 147 -27 207 -6 61 -15 114 -19 118 -4 4 -13 -27
-19 -70 -16 -110 -30 -156 -47 -149 -19 7 -24 -14 -32 -115 -5 -78 -8 -89 -24
-89 -16 0 -19 8 -19 48 0 92 -13 241 -21 237 -9 -6 -16 71 -24 255 -6 130 -39
525 -51 603 -8 49 -25 43 -41 -13 -18 -63 -61 -420 -73 -610 -6 -91 -15 -199
-20 -240 -5 -41 -9 -111 -10 -155 -1 -125 -1 -125 -76 -125 -60 0 -64 2 -64
23 0 12 -5 29 -10 37 -7 11 -10 5 -10 -22 0 -21 -4 -38 -9 -38 -10 0 -21 48
-21 91 0 30 -14 39 -23 15 -3 -7 -9 -34 -12 -60 l-7 -46 -58 0 c-68 0 -70 2
-70 103 -1 142 -28 363 -50 406 -21 43 -26 46 -49 32 -13 -8 -28 -172 -30
-328 -1 -47 -16 -59 -19 -15 -4 57 -22 418 -22 445 0 15 -4 27 -9 27 -5 0 -11
-69 -15 -152 -11 -256 -17 -268 -37 -75 -16 144 -21 171 -38 185 -15 12 -24
38 -31 92 -6 41 -17 104 -25 140 -8 36 -20 100 -26 143 -6 42 -15 77 -18 77
-4 0 -15 -107 -25 -237 -20 -280 -64 -788 -72 -821 -4 -21 -9 -23 -67 -20 -58
3 -62 5 -65 28 -6 41 -19 44 -26 5 l-7 -36 -67 3 -67 3 -6 120 c-10 195 -30
428 -39 460 l-8 30 -1 -31 c-1 -17 -4 -46 -8 -65 -5 -28 -7 -30 -14 -14 -4 11
-8 41 -8 67 -1 26 -5 49 -10 52 -11 7 -21 -94 -21 -219 0 -137 -11 -288 -21
-278 -4 4 -15 97 -23 205 -9 109 -17 203 -17 210 -4 35 -18 -93 -25 -217 l-8
-140 -12 175 c-6 96 -15 228 -19 294 -4 74 -10 114 -16 105 -5 -8 -9 -24 -9
-37 0 -12 -9 -31 -20 -42 -11 -11 -23 -34 -27 -51 -4 -20 -14 -34 -29 -40 -13
-4 -24 -14 -24 -21 0 -17 -28 -277 -36 -346 -11 -86 -25 -78 -39 21 -3 26 -10
47 -14 47 -4 0 -14 -52 -21 -115 -7 -63 -16 -117 -20 -120 -4 -2 -15 51 -24
118 -10 67 -21 125 -25 130 -4 4 -17 -6 -28 -21 -21 -28 -53 -179 -53 -249 l0
-33 -74 0 -74 0 -7 88 c-4 48 -10 107 -14 132 l-8 45 -8 -55 c-7 -46 -10 -51
-15 -29 -4 14 -11 65 -15 112 -4 48 -11 89 -15 92 -5 3 -11 -18 -14 -47 -8
-81 -26 -294 -26 -312 0 -9 -4 -16 -8 -16 -8 0 -32 270 -32 363 0 95 -18 35
-25 -83 -4 -66 -11 -118 -15 -115 -4 3 -11 39 -15 80 -7 80 -19 96 -29 40 -10
-50 -22 -51 -34 -2 -33 126 -52 214 -52 236 0 14 -4 33 -9 40 -8 12 -11 10
-14 -10 -12 -60 -41 -264 -51 -364 -7 -63 -20 -128 -31 -152 -17 -39 -22 -43
-55 -43 l-36 0 -12 123 c-7 67 -12 148 -12 179 0 61 -47 448 -55 456 -3 3 -7
3 -9 1 -2 -2 -14 -137 -26 -299 -12 -162 -25 -331 -28 -375 l-7 -80 -36 -3
c-46 -4 -49 4 -49 168 0 159 -17 447 -29 499 -5 22 -16 47 -25 56 -9 9 -16 33
-17 53 0 20 -4 46 -8 57 -12 30 -20 -65 -32 -355 -10 -254 -20 -359 -32 -330
-9 24 -26 220 -20 236 3 8 1 14 -5 14 -10 0 -14 -44 -28 -254 -11 -168 -21
-161 -28 19 -6 152 -39 514 -53 588 -7 33 -23 18 -23 -22 0 -19 -3 -21 -14
-12 -16 14 -18 7 -41 -183 -8 -65 -16 -121 -18 -123 -3 -2 -8 22 -11 54 -4 32
-10 67 -14 78 -8 27 -20 -56 -21 -155 -1 -41 -8 -120 -16 -175 -8 -55 -17
-126 -21 -157 l-5 -58 -64 0 -63 0 -6 68 c-3 37 -8 121 -11 187 -6 114 -28
250 -45 269 -5 4 -11 -18 -15 -50 -4 -33 -11 -77 -17 -99 -29 -123 -34 -140
-43 -140 -5 0 -12 13 -15 29 -3 17 -9 29 -15 28 -6 -1 -12 48 -16 123 -4 69
-9 128 -12 131 -3 3 -9 -15 -12 -41 -4 -25 -9 -44 -11 -43 -2 2 -8 55 -14 118
-17 197 -33 320 -42 320 -4 0 -8 -33 -8 -72 0 -91 -18 -353 -26 -392 -10 -47
-22 -11 -30 93 -11 146 -20 87 -33 -209 -13 -287 -17 -320 -36 -320 -10 0 -15
32 -19 118 -12 213 -44 486 -75 624 -6 24 -15 104 -21 178 -11 140 -18 185
-25 178 -11 -11 -65 -500 -75 -683 -7 -110 -17 -209 -22 -219 -6 -11 -13 -59
-16 -108 l-5 -88 -132 0 -132 0 -6 29 c-9 43 -37 297 -41 371 -2 36 -8 133
-15 215 -6 83 -16 244 -22 360 -7 115 -15 200 -19 190 -4 -11 -13 -150 -20
-310 -24 -559 -27 -491 -29 597 -1 1089 -1 1098 -22 1153 -28 76 -108 156
-184 184 -52 20 -75 21 -358 20 -280 0 -306 -2 -355 -21z"/>
<path d="M1426 5666 c-465 -293 -852 -719 -1105 -1219 -311 -616 -399 -1347
-245 -2034 54 -240 122 -431 244 -678 247 -503 643 -940 1118 -1234 l82 -51 0
2635 c0 1449 -2 2635 -3 2635 -2 0 -43 -24 -91 -54z"/>
<path d="M11280 3085 l0 -2635 83 51 c917 569 1471 1602 1434 2679 -27 769
-323 1472 -852 2018 -189 195 -438 396 -615 495 l-50 28 0 -2636z"/>
</g>
</svg>'''.encode('utf-8')
return(svg)
# svg smell
def design_svg3(strokecolor, fillcolor, width, height):
trans = str(((800 - height)/2) - 80)
svg = f'''<?xml version="1.0" encoding="utf-8"?>
<svg width="{width}" height="{height}" viewBox="13 -4 461 455" xmlns="http://www.w3.org/2000/svg" xmlns:bx="https://www.boxy-svg.com/bx">
<g>
<g transform="matrix(1.013029, -2.172449, 0.805123, 0.375435, -239.771591, 474.13916)" stroke="{strokecolor}" fill="{fillcolor}">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgba(222, 45, 94, 0.74902);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgba(222, 45, 94, 0.74902);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(-1.013029, 2.172449, -0.805123, -0.375435, 723.009949, -31.281298)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgba(222, 44, 94, 0.74902);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgba(222, 44, 94, 0.74902);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(-2.172449, 1.01303, -0.375434, -0.805124, 764.117188, 339.656342)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgba(105, 191, 237, 0.74902);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgba(105, 191, 237, 0.74902);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(2.252473, -0.819834, 0.303835, 0.834781, -276.796417, 66.121117)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgba(105, 191, 237, 0.74902);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgba(105, 191, 237, 0.74902);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(-0.819834, -2.252474, 0.834782, -0.303835, 84.025528, 743.653931)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgba(105, 191, 237, 0.74902);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgba(105, 191, 237, 0.74902);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(0.819834, 2.252473, -0.834781, 0.303835, 405.30777, -296.224701)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgba(105, 191, 237, 0.74902);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgba(105, 191, 237, 0.74902);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(-2.172449, -1.013029, 0.375435, -0.805123, 494.329376, 705.10553)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgba(168, 66, 171, 0.74902);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgba(168, 66, 171, 0.74902);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(2.172449, 1.013029, -0.375435, 0.805123, -10.540039, -257.099365)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgba(168, 66, 171, 0.74902);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgba(168, 66, 171, 0.74902);" bx:origin="0.729 0.5"/>
</g>
<g>
<g transform="matrix(0.678571, 0, 0, 0.717326, 121.009552, -24.106068)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(0, 0.678571, -0.717326, 0, 492.233185, 101.835365)">
<path transform="translate(20, {trans})"="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(0, 0.678571, -0.717326, 0, 314.712097, 103.359146)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(0.678571, 0, 0, 0.717326, 122.53334, 153.415024)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(0.479822, 0.479822, -0.507226, 0.507226, 338.366028, -43.240444)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(-0.479822, -0.479822, 0.507226, -0.507226, 148.681854, 489.907806)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(0.479822, -0.479822, 0.507226, 0.507226, -23.812111, 129.253433)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.729 0.5"/>
</g>
<g transform="matrix(-0.479822, 0.479822, -0.507226, -0.507226, 509.336121, 317.41394)">
<path transform="translate(20, {trans})" d="M 177.62 98.002 C 141.811 170.89 142.573 254.444 179.906 348.665" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.265 0.5"/>
<path transform="translate(20, {trans})" d="M 176.858 98.002 C 211.905 173.175 212.921 256.476 179.906 347.903" style="stroke: none; fill: rgb(229, 241, 50);" bx:origin="0.729 0.5"/>
</g>
<ellipse style="fill: rgb(222, 141, 20);" cx="242.767" cy="223.713" rx="26.285" ry="25.904"/>
</g>
</g>
</svg>'''.encode('utf-8')
return(svg)
# svg touch
def design_svg4(strokecolor, fillcolor, width, height):
trans = str(((800 - height)/2) - 80)
svg = f'''<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" x="0px" y="0px"
width="{width}" height="{height}" viewBox="0 0 1000 1000" stroke="{strokecolor}" fill="{fillcolor}" enable-background="new 0 0 1000 1000" xml:space="preserve">
<g>
<path transform="translate(20, {trans})" d="M925.9,538.3c-31.9-31.9-78.9-34.8-110.8-2.9l-91.2,91.1c-23.7,23.7-52.3,23.7-69,4c-11.1-13.1-6.7-53.3-3.6-78.9L697,175.8c4.1-33.6-19.8-66-53.4-70.1c-33.6-4.1-64.1,21.7-68.2,55.3l-50.4,295.3c-2.6,7.3-8.3,8.6-8.9-1.3L498.8,71.3c0-33.8-27.4-61.3-61.3-61.3c-33.8,0-61.3,27.4-61.3,61.3L375,457.9c0.3,4.5-3.5,5.7-4.2,0.6l-54.5-301.8c-6-33.3-37.9-57.3-71.2-51.3c-33.3,6-55.4,39.8-49.4,73.1l48.5,353.2c0,6.3-2.1,9.9-5,1.8l-72.4-193.6c-11.3-31.9-46.4-50.5-78.3-39.1c-31.9,11.3-48.6,48.3-37.2,80.1l127,414.8c0.7,2.3,1.4,4.6,2.1,6.8l0.3,0.9c0,0.1,0.1,0.1,0.1,0.2C215.8,911.8,317.5,990,437.5,990c76.8,0,156.6-27.1,217.3-73.7l0,0c65.6-39.5,275.8-265.4,275.8-265.4C962.5,619,957.8,570.2,925.9,538.3L925.9,538.3z"/>
</g>
</svg>'''.encode('utf-8')
return(svg)
# svg taste
def design_svg5(strokecolor, fillcolor, width, height):
trans = str(((800 - height)/2) - 80)
svg = f'''<svg xmlns="http://www.w3.org/2000/svg" idth="{width}" height="{height}" viewBox="0 0 229.772 303.098" stroke="{strokecolor}" fill="{fillcolor}" >
<g id="bear" transform="translate(-107.65 -107.937)">
<path transform="translate(20, {trans})" id="Pfad_59" data-name="Pfad 59" d="M336.974,234.551c4.865-26.722-30.813-34.375-59.007-48.1-15.58-10.2-30.467-39.336-35.11-53.188-.428-5.464,3.063-30.312-7.24-24.433-6.486,3.7-15.822,14.434-33.132,16.141-12.467,1.23-19.593,5.522-25.223,15.078-4.729,8.028-15.981-2.035-19.379,9.322-1.524,5.092,9.058,10.26,10.356,17,1.189,36.732-2.887,63.369-28.895,94.6-3.482,4.182-15.336,11.306-16.1,19.165-1.348,13.913,1.265,30.885,11.71,32.58s24.332.547,24.332-12.368c0-10.17-.164-13.447-1.656-15.748s-7.642-2.6-7.642-2.6a9.265,9.265,0,0,1,0-5.7,22.2,22.2,0,0,1,3.939-5.722,23.738,23.738,0,0,1,10.643-7.275c12.162-3.813,24.465-2.063,35.232.331,15.847,3.523,29.2,12.538,34.113,20.6,3.349,5.5,9.571,27,3.294,28.514.5,5.062,1.885,16.509-2.622,16.967-.716,3.844-1.252,14.3-6.416,13.88-2.216,10.266-3.553,14.048-7.021,14.428-3.676-8.315-9.833-17.367-26.39-17.367-21.941,0-13.389,35.96-13.389,35.96s-26.72-.723-31.591-10c-2.47-4.7-3.019-7.926-3.737-9.827-2.779.117-4.9-4.682-5.178-14.886-1.03-1.385-7.349-11.66-25.094-5.9-11.977,3.887-8.257,28.131-4.278,42.416s16.393,15.71,34.546,16.92,39.81-1.176,39.81-1.176,3.708,17.8,23.353,16.835,52.932-5.417,63.686-8.374c18.555-5.1,39.711-6.424,49.779-38.342,10.729-34.01,2.108-61.79-6.673-100.691C327.039,257.433,334.311,249.174,336.974,234.551ZM198.079,174.833c-5.455-.286-8.469-7.856-9.285-9.527,5.847-2.2,9.257-10.791-.616-9.418-10.59,1.472-6.822,9.927-2.058,9.926a6.971,6.971,0,0,0,1-.079c.368,1.268,2.429,8.758.646,10.811-11.795-2.055-19.565-22.684,7.408-26.434C221.3,146.479,212.8,168.647,198.079,174.833Z" transform="translate(0 0)"/>
<path transform="translate(20, {trans})" id="Pfad_60" data-name="Pfad 60" d="M246.082,340.683c1.282-5.021-12.455-13.594-29.1-17.624s-29.906-1.989-31.188,3.032,11.176,12.357,27.825,16.386S244.8,345.7,246.082,340.683Z" transform="translate(-20.094 -54.835)"/>
<path transform="translate(20, {trans})" id="Pfad_61" data-name="Pfad 61" d="M297.978,248.048c-5.224,3.085-3.043,10.421-1.9,14.194.746,2.469.128,6.1-2.623,6.069-2.777-.034-3.163-3.7-2.417-6.248,1.324-4.519,2.044-8.386-.772-12.746-2.126-3.292-6.686-2.195-7.989,2.5-4.444,17.312,2.8,28.909,2.846,35.367.029,4.2-1.99,8.074-4.937,8.074-3.306,0-5.4-3.591-5.5-7.714-.167-6.69,6.024-23.739-.61-34.386-7.1-11.4-22.173-2.695-16.584,13.437-8.229-3.806-9.755-15.155-7.955-20.3.979-2.795,2.743-2.777,4.32-5.04,1.778-2.551.888-5.805,3.6-8.846,2.263-2.537,5.489-1.1,7.886-3.635,2.332-2.468,3.154-4.937,6.909-5.279,15.88-1.451,19.914,13.263,36.1,18.867,6.422,2.026,9.183,2.8,21.234,4.477C318.652,253.294,304.089,244.826,297.978,248.048Z" transform="translate(-36.355 -29.727)" fill="#daa03d"/>
</g>
</svg>'''.encode('utf-8')
return(svg)

View file

@ -3,16 +3,34 @@ import sys
import re import re
from krita import * from krita import *
from textblob import TextBlob
from textblob_de import TextBlobDE
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
from PyQt5.QtGui import * from PyQt5.QtGui import *
from PyQt5.QtCore import * from PyQt5.QtCore import *
from html.parser import HTMLParser
import urllib.request
from wordart.classes import *
from wordart.svg_vorlagen import *
from .classes import * # define class HTML-Parser
from .svg_vorlagen import * class MyHTMLParser(HTMLParser):
def __init__(self):
super().__init__()
self.data = []
self.capture = False
def handle_starttag(self, tag, attrs):
if tag in ('p', 'h1'):
self.capture = True
def handle_endtag(self, tag):
if tag in ('p', 'h1'):
self.capture = False
def handle_data(self, data):
if self.capture:
self.data.append(data)
class DockerLinkGrepper(DockWidget): class DockerLinkGrepper(DockWidget):
@ -49,8 +67,6 @@ class DockerLinkGrepper(DockWidget):
# write some actions # write some actions
clicked = 'Button clicked' clicked = 'Button clicked'
parser = MyHTMLParser()
content = line.text()
#add a checkbox #add a checkbox
newCheckbox = QCheckBox() newCheckbox = QCheckBox()
@ -59,81 +75,30 @@ class DockerLinkGrepper(DockWidget):
mainWidget.setLayout(layoutForButtons) mainWidget.setLayout(layoutForButtons)
mainWidget.layout().addWidget(newButton) mainWidget.layout().addWidget(newButton)
newButton.clicked.connect(lambda: newCheckbox.setCheckState(2)) #newButton.clicked.connect(lambda: newCheckbox.setCheckState(2))
newCheckbox.clicked.connect(lambda: parser.feed(urllib.request.urlopen(content).read().decode())) newButton.clicked.connect(lambda: newButtonIsClicked())
#parser.feed(urllib.request.urlopen(content).read().decode()) #newButton.clicked.connect(lambda: makeart(content, parser))
#link = urllib.request.urlopen(content).read().decode()
linkdata = parser.data
# language #newCheckbox.clicked.connect(lambda: parser.feed(urllib.request.urlopen(content).read().decode()))
language = '' #newButton.clicked.connect(self.newButtonIsClicked(content))
# filtering parsed text #global parser
text = "" #parser = MyHTMLParser()
for phrases in linkdata: #if line.text():
#print (phrases) #makeart(line.text(), parser)
#print('pre: ' + phrases) #newCheckbox.clicked.connect(makeart(content, parser))
phrases = phrases.rstrip("\n\r+0-9[]()+")
#print('after: ' + phrases)
# skip unwanted characters
text = text + phrases
#print('get: ' + phrases)
#print(text) def newButtonIsClicked():
# create textblob # text = 'Welcome fellow human beeing ^.^
blob = TextBlob(text) # aktivate Checkbox if input is done
#print(blob.tags) newCheckbox.setCheckState(2)
if line.text():
parser = MyHTMLParser()
makeart(line.text(), parser)
for w in blob.words: else:
if re.match(r"and", w): newCheckbox.setCheckState(1)
language = 'en'
elif re.match(r"und", w):
language = 'de'
#print(language)
if language == 'de':
blob = TextBlobDE(text)
sentence_lens = []
commas = []
polarity = []
# print polarity of sentences
for sentence in blob.sentences:
# length of sentences
sentence_lens.append(len(sentence))
# number of commas
commas.append(len(re.findall(',', str(sentence))))
# polarity
polarity.append(sentence.sentiment.polarity)
# init new textforart object
#art = textforart(self, language, sentence_lens, blob.sentences, commas, polarity)
# make art out of object
# width: 0 - 700
# height: 0 - 700
# fill color:#000000 # stroke color:#000000
#stroke = "rgb(" + str(round(125*(1/art.mean_number_commas))) + ", " + str(round(125 - art.min_sentences_polarity)) + ", " + str(round(125 - art.max_sentences_polarity)) + ")"
#fill = "rgb(" + str(round(125*(1/art.mean_number_commas))) + ", " + str(round(125 - art.min_sentences_polarity)) + ", " + str(round(125 - art.max_sentences_polarity)) + ")"
#ImageColor.getcolor("#23a9dd", "RGB")
stroke = "rgb(255, 255, 255)"
stroke = "rgb(255, 254, 94.)"
#fill = "rgb(255, 255, 255)"
# define with of svg
#heigh = 700- (10000*art.mean_sentences_polarity)
#width = 700*art.mean_number_commas
#svg = design_svg(stroke, fill, 700, 700)
#create_svg(svg)
def canvasChanged(self, canvas): def canvasChanged(self, canvas):
pass pass