Bladeren bron

more knobs to twist

Malf 5 maanden geleden
bovenliggende
commit
ec8a1f3927

+ 7 - 0
.vscode/launch.json

@@ -0,0 +1,7 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": []
+}

BIN
aSide/aSide-0-0.png


BIN
aSide/aSide-0-1.png


BIN
aSide/aSide-1-0.png


BIN
aSide/aSide-1-1.png


BIN
aSide/aSide-2-0.png


BIN
aSide/aSide-2-1.png


BIN
aSide/aSide-3-0.png


BIN
aSide/aSide-3-1.png


BIN
aSide/aSide.png


BIN
aSide/out.png


BIN
aSide/out0-0.png


BIN
aSide/out1-0.png


BIN
aSide/out2-0.png


BIN
bSide/bSide-0-0.png


BIN
bSide/bSide-0-1.png


BIN
bSide/bSide-1-0.png


BIN
bSide/bSide-1-1.png


BIN
bSide/bSide-2-0.png


BIN
bSide/bSide-2-1.png


BIN
bSide/bSide-3-0.png


BIN
bSide/bSide-3-1.png


BIN
bSide/bSide.png


BIN
bSide/out.png


BIN
bSide/out0-0.png


BIN
bSide/out1-0.png


BIN
bSide/out2-0.png


+ 72 - 29
main.py

@@ -14,31 +14,44 @@ class Pipe:
 
 class Series:
     def __init__(self, **params):
+        self.name = params.get("name", "out")
         self.pos = (params.get("posX",0), params.get("posY",0))
         self.size = params.get("size",100)
         self.resolution = params.get("resolution",300)
-        self.stepSize = params.get("stepSize",20)
-        self.spacer = params.get("spacer",10)
+        self.x_dpi = self.resolution * 25.4
+        self.y_dpi = self.resolution * 25.4
+        self.stepSize = params.get("stepSize",30)
+        self.tilt = params.get("tilt",20)
+        self.spacer = params.get("spacer",20)
         self.sequence = params.get("sequence",(3,2,1,0))
 
     def draw(self, im):
         draw = ImageDraw.Draw(im)
         idx = 0
         end = (0,0)
-        prevEnd = (self.pos[0]-self.spacer, self.pos[1]-self.sequence[0]*self.stepSize-self.size/2)
+        prevEnd = (self.pos[0]-self.spacer, self.pos[1]-self.sequence[0]*self.tilt-self.size/2)
         for height in self.sequence:
-            stepBios = height*self.stepSize
+            tiltBios = height*self.tilt
+            stepBios = idx*self.stepSize
             idxBios = idx*self.size
             spacerBios = idx*self.spacer
-            pipe = Pipe(posX=self.pos[0]+idxBios+spacerBios+self.spacer, posY=self.pos[1]-stepBios, size=self.size, resolution=self.resolution)
+            pipe = Pipe(posX=self.pos[0]+idxBios+spacerBios+self.spacer, posY=self.pos[1]-tiltBios-stepBios, size=self.size, resolution=self.resolution)
             pipe.draw(im)
 
             end = (pipe.pos[0]+pipe.size, pipe.pos[1]-pipe.size/2)
-            shape = [(end[0]*self.resolution,end[1]*self.resolution), ((end[0]+self.spacer)*self.resolution, end[1]*self.resolution)]
-            draw.line(shape, fill =255, width = 2)
 
-            shape = [((prevEnd[0]+self.spacer)*self.resolution,prevEnd[1]*self.resolution), ((end[0]-pipe.size)*self.resolution,end[1]*self.resolution)]
-            draw.line(shape, fill =255, width = 2)
+            if prevEnd[1] < end[1]:
+                shape = [(end[0]*self.resolution,end[1]*self.resolution), ((end[0]+self.spacer)*self.resolution, end[1]*self.resolution)]
+                draw.line(shape, fill =255, width = 2)
+
+                shape = [((prevEnd[0]+self.spacer)*self.resolution,prevEnd[1]*self.resolution), ((end[0]-pipe.size)*self.resolution,end[1]*self.resolution)]
+                draw.line(shape, fill =255, width = 2)
+            else:
+                shape = [((prevEnd[0])*self.resolution,prevEnd[1]*self.resolution), ((prevEnd[0])*self.resolution,end[1]*self.resolution)]
+                draw.line(shape, fill =255, width = 2)
+
+                shape = [((prevEnd[0])*self.resolution,end[1]*self.resolution), ((end[0]-pipe.size)*self.resolution, end[1]*self.resolution)]
+                draw.line(shape, fill =255, width = 2)
             
             prevEnd = end
             idx+=1
@@ -46,36 +59,66 @@ class Series:
         shape = [(self.pos[0]*self.resolution,(self.pos[1]+10)*self.resolution), ((end[0]+self.spacer)*self.resolution, (self.pos[1]+10)*self.resolution)]
         draw.line(shape, fill =255, width = 2)
 
+        shape = [((end[0])*self.resolution, end[1]*self.resolution), ((end[0]+self.spacer)*self.resolution, end[1]*self.resolution)]
+        draw.line(shape, fill =255, width = 2)
+
         shape = [((end[0]+self.spacer)*self.resolution,(self.pos[1]+10)*self.resolution), ((end[0]+self.spacer)*self.resolution, end[1]*self.resolution)]
         draw.line(shape, fill =255, width = 2)
 
-        shape = [(self.pos[0]*self.resolution,(self.pos[1]+10)*self.resolution), (self.pos[0]*self.resolution, (self.pos[1]-self.sequence[0]*self.stepSize-self.size/2)*self.resolution)]
+        shape = [(self.pos[0]*self.resolution,(self.pos[1]+10)*self.resolution), (self.pos[0]*self.resolution, (self.pos[1]-self.sequence[0]*self.tilt-self.size/2)*self.resolution)]
         draw.line(shape, fill =255, width = 2)
     
-def crop(im, imSize, x_dpi, y_dpi, resolution=10, tileSize=(280, 180)):
-    numTilesX = math.ceil((imSize[0] / resolution) / tileSize[0])
-    numTilesY = math.ceil((imSize[1] / resolution) / tileSize[1])
-    for y in range(0,numTilesY):
-        for x in range(0,numTilesX):
-            x0=x*tileSize[0]*resolution
-            y0=y*tileSize[1]*resolution
-            x1=x0+tileSize[0]*resolution
-            y1=y0+tileSize[1]*resolution
-            subIm = im.crop((x0, y0, x1, y1))
-            ImageOps.invert(subIm).save("out%s-%s.png"%(x,y), dpi=(x_dpi, y_dpi))
+    def cropNsave(self, im, imSize, tileSize=(180, 280)):
+        numTilesX = math.ceil((imSize[0] / self.resolution) / tileSize[0])
+        numTilesY = math.ceil((imSize[1] / self.resolution) / tileSize[1])
+        for y in range(0,numTilesY):
+            for x in range(0,numTilesX):
+                x0=x*tileSize[0]*self.resolution
+                y0=y*tileSize[1]*self.resolution
+                x1=x0+tileSize[0]*self.resolution
+                y1=y0+tileSize[1]*self.resolution
+                subIm = im.crop((x0, y0, x1, y1))
+                self.drawMarker(subIm, tileSize)
+                ImageOps.invert(subIm).save("%s-%s-%s.png"%(self.name,x,y), dpi=(self.x_dpi, self.y_dpi))
+
+    def drawMarker(self, subIm, tileSize):
+        x0 = 0
+        y0 = 0
+        x1 = tileSize[0]*self.resolution
+        y1 = tileSize[1]*self.resolution
+        length = 40
+        draw = ImageDraw.Draw(subIm)
+        shapes = [
+            [(x0,y0), (x0+length,y0)],
+            [(x0,y0), (x0,y0+length)],
+
+            [(x0,y1), (x0+length,y1)],
+            [(x0,y1), (x0,y1-length)],
 
+            [(x1,y0), (x1-length,y0)],
+            [(x1,y0), (x1,y0+length)],
+
+            [(x1,y1), (x1-length,y1)],
+            [(x1,y1), (x1,y1-length)]
+        ]
+        for shape in shapes:
+            draw.line(shape, fill =200, width = 20)
 
 def main():
-    imSize = (7000, 1800)
+    imSize = (7000, 5599)
     resolution = 10
+
     im = Image.new('L', imSize, 0)
-    #aSide = Series(posX=50, posY=150, sequence=(4,4,2,2,0), resolution=resolution, size=110)
-    #aSide.draw(im)
-    bSide = Series(posX=50, posY=160, sequence=(5,3,3,1,1), resolution=resolution, size=110)
+    aSide = Series(name="aSide", posX=10, posY=300, sequence=(0,2,2,4,4), resolution=resolution, size=110)
+    aSide.draw(im)
+    ImageOps.invert(im).save("aSide.png", dpi=(aSide.x_dpi, aSide.y_dpi))
+    aSide.cropNsave(im, imSize)
+
+    im = Image.new('L', imSize, 0)
+    bSide = Series(name="bSide",posX=10, posY=300, sequence=(1,1,3,3,5), resolution=resolution, size=110)
     bSide.draw(im)
-    x_dpi = resolution * 25.4
-    y_dpi = resolution * 25.4
-    ImageOps.invert(im).save("out.png", dpi=(x_dpi, y_dpi))
-    crop(im, imSize, x_dpi, y_dpi)
+    ImageOps.invert(im).save("bSide.png", dpi=(bSide.x_dpi, bSide.y_dpi))
+    bSide.cropNsave(im, imSize)
+    
 
 main()