Ver Fonte

TODO: Refactor variable pass around completed.

david há 5 anos atrás
pai
commit
41e5ba428e
2 ficheiros alterados com 9 adições e 8 exclusões
  1. 1 0
      TODO.md
  2. 8 8
      dataLoad.py

+ 1 - 0
TODO.md

@@ -10,4 +10,5 @@
 * Document Functions (COMPLETE)
 * Change from `global` to pass around (COMPLETE)
 * Change `save_image()` to `output_image()` (COMPLETE)
+* Refactor variable pass around (COMPLETE)
 * Move all the image stuff over to it's own

+ 8 - 8
dataLoad.py

@@ -76,7 +76,7 @@ def img_point(pix, x, y):
     """
     return pix[x, y]
 
-def img_avg(im, pal, pix, x, y):
+def img_avg(pix, x, y):
     """
     img_avg, returns the average brightness 0-255,
     given the x and y on the image calls img_point,
@@ -92,7 +92,7 @@ def img_avg(im, pal, pix, x, y):
 
     return int( ( rgb[0] + rgb[1] + rgb[2] ) / 3 )
 
-def is_set(im, pal, pix, x, y):
+def is_set(pix, x, y):
     global INTENSITY
     """
     is_set, returns True or False of calculating,
@@ -105,7 +105,7 @@ def is_set(im, pal, pix, x, y):
     False means the brightness at the given x and y,
     is Greater Than which means its bright.
     """
-    avg = img_avg(im, pal, pix, x,y)
+    avg = img_avg(pix, x,y)
     return (avg < INTENSITY)
 
 def scan_img(im, pal, pix, size):
@@ -124,7 +124,7 @@ def scan_img(im, pal, pix, size):
 
     for y in range( 0,size[1] ):
         for x in range( 0,size[0] ):
-            pnt_is = is_set(im, pal, pix, x,y)
+            pnt_is = is_set(pix, x,y)
             if (pnt_is):
                 total += 1
                 if x < sx:
@@ -151,7 +151,7 @@ def scan_img(im, pal, pix, size):
     #print (sx,ex,sy,ey)
     return(sx,sy,ex,ey,total)
 
-def output_image(im, pal, pix, size):
+def output_image(pix, size):
     """
     For the size of the area we have reduced down to where the majority of dark pixels,
     are located, store all that into a list and return the list.
@@ -166,7 +166,7 @@ def output_image(im, pal, pix, size):
     for y in range(sy,ey):
         s = ''
         for x in range(sx,ex):
-            if is_set(im, pal, pix, x,y):
+            if is_set(pix, x,y):
                 s += ON
             else:
                 s += OFF
@@ -206,11 +206,11 @@ def run(difficult):
         ey = size[1]
         total = 0
 
-        sx, sy, ex, ey, total = scan_img(im, pal, pix, size)
+        sx, sy, ex, ey, total = scan_img(pix, size)
 
         print(f"Chars within ({sx}, {sy}) - ({ex}, {ey}) total {total} pixels")
 
-        img_s = output_image(im, pal, pix, size)
+        img_s = output_image(pix, size)
         for l in img_s:
             print(l)
         word = input('Word: ')