# Create graph using makeGraph.py
# Use Paint or GIMP to fill the grids in with black.
# Use readGraph.py to create a byte-oriented bitmap of values to
# copy and place into Arduino sketch.



from PIL import Image, ImageDraw
from math import cos, sin, pi, radians


def point_on_circle(center, radius, degree):
    '''
        Finding the x,y coordinates on circle, based on given angle
        https://stackoverflow.com/questions/35402609/point-on-circle-base-on-given-angle
    '''
    #center of circle, angle in degree and radius of circle
    angle = radians(degree)
    x = center[0] + (radius * cos(angle))
    y = center[1] + (radius * sin(angle))

    return x,y


center = [400, 400]

im = Image.open('heart.png')
im = im.rotate(90)  # PIL.Image 0,0 = upper left, most image programs, lower left

z = 31 # number of pixels per LED

#152 to 400

outTxt = 'const char PROGMEM shape_1[] = {\n'
for degree in range(0, 360, 5):
    outByteStr = '  B'
    for LED in range(8):
        x1, y1 = point_on_circle(center, 152 + 5 + LED * 31, degree + 2) # five pixels up, 2 deg over
        val = im.getpixel((x1, y1))
        #print(val)
        if val[0] == 255:
            outByteStr += '0' #I'm black
        else:
            outByteStr += '1' #I'm white . . .
    #print(outByteStr)   
    outTxt = outTxt + outByteStr + ',\n'
outTxt += '};\n'

print(outTxt)







