Cybrkyd's git repositories

imaging-with-python • commit: 6c5d2b4

commit 6c5d2b46491184cb3727f08ac2f51d073edbb7d09366677d5c5deac2d76a17b7
author cybrkyd <116197215+cybrkyd@users.noreply.github.com> 2023-02-13 11:19:56 +0000
committer cybrkyd <116197215+cybrkyd@users.noreply.github.com> 2023-02-13 11:19:56 +0000

Commit Message

gradients.py

📊 Diffstat

gradients.py 23
1 files changed, 23 insertions(+), 0 deletions(-)

Diff

diff --git a/gradients.py b/gradients.py
new file mode 100644
index 0000000..184fa25
--- /dev/null
+++ b/gradients.py
@@ -0,0 +1,23 @@
+ import random
+
+ class rand():
+ def __str__(self):
+ return str(random.randint(0, 100))
+
+ class rgbset():
+ def __str__(self):
+ return str(random.randint(0, 255))
+
+ ran = rand()
+ rgb = rgbset()
+
+ svg1 = '<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1400 400">\n<rect width="1400" height="400"/>\n<defs>\n'
+ svg2 = '<linearGradient id="a" x1="'+str(ran)+'%" y1="'+str(ran)+'%" x2="'+str(ran)+'%" y2="'+str(ran)+'%">\n'
+ svg3 = '<stop offset="0%" style="stop-color:rgb('+str(rgb)+','+str(rgb)+','+str(rgb)+');stop-opacity:1" />\n'
+ svg4 = '<stop offset="100%" style="stop-color:rgb('+str(rgb)+','+str(rgb)+','+str(rgb)+');stop-opacity:1" />\n'
+ svg5 = '</linearGradient>\n</defs>\n<rect fill="url(#a)" width="1400" height="400"/>\n</svg>'
+
+ # write to file
+ file = open("grad.svg", "w")
+ file.writelines("%s%s%s%s%s" % (svg1,svg2,svg3,svg4,svg5))
+ file.close()