This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def luminance(r,g,b): | |
return math.sqrt(0.299 * math.pow(r,2) + 0.587 * math.pow(g,2) + 0.114 * math.pow(b,2)) | |
def tint_to_lum(color, lum): | |
r,g,b = color | |
nR,nG,nB = r,g,b | |
while True: | |
tint_factor = .005 | |
nR = nR + (255 - nR) * tint_factor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEG30 = 30/360. | |
def adjacent_colors((r, g, b), d=DEG30): # Assumption: r, g, b in [0, 255] | |
r, g, b = map(lambda x: x/255., [r, g, b]) # Convert to [0, 1] | |
h, l, s = colorsys.rgb_to_hls(r, g, b) # RGB -> HLS | |
h = [(h+d) % 1 for d in (-d, d)] # Rotation by d | |
adjacent = [map(lambda x: int(round(x*255)), colorsys.hls_to_rgb(hi, l, s)) | |
for hi in h] # H'LS -> new RGB | |
adjacent[0] = tuple(adjacent[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def average_color(image): | |
w,h = image.size | |
x0,y0 = (0,0) | |
x1,y1 = (w,h) | |
r,g,b = 0,0,0 | |
area = w*h | |
for x in range(x0, x1): | |
for y in range(y0, y1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_slope(img_seg): | |
x,y = np.where(img_seg==True) | |
slope,_ = np.polyfit(x,y,1) | |
return -1*slope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name of your app. | |
APP="mosaicshapes" | |
# The path of your app to sign. | |
APP_PATH="/Users/dean/Desktop/m/mosaicshapes.app" | |
# The path to the location you want to put the signed package. | |
RESULT_PATH="/Users/dean/Desktop/$APP.pkg" | |
# The name of certificates you requested. | |
APP_KEY="3rd Party Mac Developer Application: [Redacted]" | |
INSTALLER_KEY="3rd Party Mac Developer Installer: [Redacted]" | |
#APP_KEY=”Developer ID Application: [redacted]” |
NewerOlder