Explorar o código

Merge branch 'dev-lazpaint' of https://github.com/bgrabitmap/lazpaint into dev-lazpaint

johann %!s(int64=5) %!d(string=hai) anos
pai
achega
486e0fad9f
Modificáronse 3 ficheiros con 74 adicións e 0 borrados
  1. 27 0
      scripts/3d_room.py
  2. 24 0
      scripts/fractal_tree.py
  3. 23 0
      scripts/fractal_tree_random.py

+ 27 - 0
scripts/3d_room.py

@@ -0,0 +1,27 @@
+from lazpaint import tools, image, layer, dialog
+
+def line(x, y, x2, y2):
+    tools.choose(tools.PEN)
+    tools.mouse([(x, y), (x2, y2)])
+    tools.keys(tools.KEY_RETURN)
+
+
+ZOOM = dialog.input_value("Zoom (Between 0.1 and 0.4 it creates a 3d room, more than 0.5 to 0.9 it creates a cross with a rectangle)", 0.25)
+
+layer.new()
+#top left
+line(0, 0, image.get_width() * ZOOM, image.get_height() * ZOOM)
+#bottom left
+line(0, image.get_height(), image.get_width() * ZOOM, image.get_height() - (image.get_height() * ZOOM))
+#top right
+line(image.get_width(), 0, image.get_width() - (image.get_width() * ZOOM), image.get_height() * ZOOM)
+#bottom right
+line(image.get_width(), image.get_height(), image.get_width() - (image.get_width() * ZOOM), image.get_height() - (image.get_height() * ZOOM))
+#top
+line(image.get_width() * ZOOM, image.get_height() * ZOOM, image.get_width() - (image.get_width() * ZOOM),  image.get_height() * ZOOM)
+#bottom
+line(image.get_width() * ZOOM, image.get_height() - (image.get_height() * ZOOM), image.get_width() - (image.get_width() * ZOOM), image.get_height() - (image.get_height() * ZOOM))
+#left
+line(image.get_width() * ZOOM, image.get_height() * ZOOM, image.get_width() * ZOOM, image.get_height() - (image.get_height() * ZOOM))
+#right
+line(image.get_width() - (image.get_width() * ZOOM), image.get_height() - (image.get_height() * ZOOM), image.get_width() - (image.get_width() * ZOOM), image.get_height() * ZOOM)

+ 24 - 0
scripts/fractal_tree.py

@@ -0,0 +1,24 @@
+from lazpaint import tools, image, layer, dialog
+import math, random
+
+def line(x, y, x2, y2):
+    tools.choose(tools.PEN)
+    tools.mouse([(x, y), (x2, y2)])
+    tools.keys(tools.KEY_RETURN)
+
+MULTIPLIER = dialog.input_value("Zoom", 10)
+ANGLE = dialog.input_value("Angle", 45)
+DEG_TO_RAD = math.pi / 180
+
+def drawTree(x1, y1, angle, depth):
+    if (depth > 0):
+        x2 = x1 + (math.cos(angle * DEG_TO_RAD) * depth * MULTIPLIER)
+        y2 = y1 + (math.sin(angle * DEG_TO_RAD) * depth * MULTIPLIER)
+        line(x1, y1, x2, y2)
+        drawTree(x2, y2, angle - ANGLE, depth - 2)
+        drawTree(x2, y2, angle + ANGLE, depth - 2)
+        drawTree(x2, y2, angle - ANGLE, depth - 2)
+        drawTree(x2, y2, angle + ANGLE, depth - 2)
+
+layer.new()
+drawTree(image.get_width() / 2, image.get_height(), -90, 14)

+ 23 - 0
scripts/fractal_tree_random.py

@@ -0,0 +1,23 @@
+from lazpaint import tools, image, layer, dialog
+import math, random
+
+def line(x, y, x2, y2):
+    tools.choose(tools.PEN)
+    tools.mouse([(x, y), (x2, y2)])
+    tools.keys(tools.KEY_RETURN)
+
+MULTIPLIER = dialog.input_value("Zoom", 10)
+DEG_TO_RAD = math.pi / 180
+
+def drawTree(x1, y1, angle, depth):
+    if (depth > 0):
+        x2 = x1 + (math.cos(angle * DEG_TO_RAD) * depth * MULTIPLIER)
+        y2 = y1 + (math.sin(angle * DEG_TO_RAD) * depth * MULTIPLIER)
+        line(x1, y1, x2, y2)
+        drawTree(x2, y2, angle - random.randint(15,50), depth - 1.44)
+        drawTree(x2, y2, angle + random.randint(10,25), depth - 0.72)
+        drawTree(x2, y2, angle - random.randint(10,25), depth - 3)
+        drawTree(x2, y2, angle + random.randint(15,50), depth - 4)
+
+layer.new()
+drawTree(image.get_width() / 2, image.get_height(), -91, 9)