Inital Commit (Creates Graphs)
4
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.~lock.Numbers.xlsx#
|
||||
gen
|
||||
planning.txt
|
||||
__pycache__
|
||||
BIN
Numbers.xlsx
Normal file
8
cords.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def center_on(image, location):
|
||||
h = image.size[0]
|
||||
w = image.size[1]
|
||||
|
||||
return (int(location[0] - (0.5 * h)),int(location[1] - (0.5 * w)))
|
||||
|
||||
def scale(image, amount):
|
||||
return image.resize((int(image.size[0] * amount), int(image.size[1] * amount)))
|
||||
BIN
fonts/Asap_Condensed/AsapCondensed-Black.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-BlackItalic.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-Bold.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-BoldItalic.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-ExtraBold.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-ExtraBoldItalic.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-ExtraLight.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-ExtraLightItalic.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-Italic.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-Light.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-LightItalic.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-Medium.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-MediumItalic.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-Regular.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-SemiBold.ttf
Normal file
BIN
fonts/Asap_Condensed/AsapCondensed-SemiBoldItalic.ttf
Normal file
93
fonts/Asap_Condensed/OFL.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2018 The Asap Project Authors (https://github.com/Omnibus-Type/Asap)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
141
graphs.py
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import matplotlib.pyplot as plt
|
||||
|
||||
def currency_fmt(num):
|
||||
return ("$"+("{:0,.2f}".format(float(num))))[:-3] # Cents are dropped from diplay
|
||||
|
||||
def make_basic_greenred(name, v1, v2):
|
||||
title = (name)
|
||||
width = 0.2
|
||||
bottom = 0
|
||||
|
||||
#setup plot
|
||||
fig, ax = plt.subplots()
|
||||
fig.patch.set_facecolor((0,0,0,0))
|
||||
ax.set_facecolor((0,0,0,0))
|
||||
|
||||
#make fist bar and offset the bottom line by it
|
||||
p = ax.bar(title, [v1], width, bottom=bottom, align='center',color='tab:green')
|
||||
ax.bar_label(p, label_type='center', fmt=currency_fmt)
|
||||
bottom += v1
|
||||
|
||||
#make second bar graph
|
||||
p = ax.bar(title, [v2], width, bottom=bottom, align='center', color='tab:red')
|
||||
ax.bar_label(p, label_type='center', fmt=currency_fmt)
|
||||
|
||||
return fig
|
||||
|
||||
#Version of green red graph with no labels
|
||||
def make_basic_greenred_NL(name, v1, v2):
|
||||
title = (name)
|
||||
width = 0.2
|
||||
bottom = 0
|
||||
|
||||
#setup plot
|
||||
fig, ax = plt.subplots()
|
||||
fig.patch.set_facecolor((0,0,0,0))
|
||||
ax.set_facecolor((0,0,0,0))
|
||||
|
||||
#make fist bar and offset the bottom line by it
|
||||
p = ax.bar(title, [v1], width, bottom=bottom, align='center',color='tab:green')
|
||||
bottom += v1
|
||||
|
||||
#make second bar graph
|
||||
p = ax.bar(title, [v2], width, bottom=bottom, align='center', color='tab:red')
|
||||
|
||||
return fig
|
||||
|
||||
|
||||
### I Mountain Grahps
|
||||
|
||||
# Generates graph for Emergency Fund
|
||||
def gen_EF(wb):
|
||||
fig = make_basic_greenred("Emergency Fund",wb["I Mountain"]["A2"].value,wb["I Mountain"]["C2"].value)
|
||||
|
||||
fig.savefig('./.gen/EF.png',dpi=300)
|
||||
|
||||
|
||||
# Generates graph for Life Insurance Tracker
|
||||
def gen_LI(wb):
|
||||
fig = make_basic_greenred("Life Insurance Tracker",wb["I Mountain"]["A7"].value,wb["I Mountain"]["C7"].value)
|
||||
|
||||
fig.savefig('./.gen/LI.png',dpi=300)
|
||||
|
||||
# Generates graph for Disability Insurance Tracker
|
||||
def gen_DI(wb):
|
||||
fig = make_basic_greenred("Disability Insurance Tracker",wb["I Mountain"]["A11"].value,wb["I Mountain"]["C11"].value)
|
||||
|
||||
fig.savefig('./.gen/DI.png',dpi=300)
|
||||
|
||||
|
||||
### O Mountain Graphs
|
||||
|
||||
# Generates graph for Roth IRA
|
||||
def gen_Roth_IRA(wb):
|
||||
fig = make_basic_greenred_NL("Roth IRA",wb["O Mountain"]["A2"].value,wb["O Mountain"]["C2"].value)
|
||||
|
||||
fig.savefig('./.gen/Roth_IRA.png',dpi=300)
|
||||
|
||||
# Generates graph for Roth Catch Up
|
||||
def gen_Roth_Catch_Up(wb):
|
||||
fig = make_basic_greenred_NL("Roth Catch Up",wb["O Mountain"]["A4"].value,wb["O Mountain"]["C4"].value)
|
||||
|
||||
fig.savefig('./.gen/Roth_Catch_Up.png',dpi=300)
|
||||
|
||||
# Generates graph for 401K contribution
|
||||
def gen_401K_Contribution(wb):
|
||||
fig = make_basic_greenred_NL("401K Contribution",wb["O Mountain"]["A6"].value,wb["O Mountain"]["C6"].value)
|
||||
|
||||
fig.savefig('./.gen/401K_Contribution.png',dpi=300)
|
||||
|
||||
# Generates graph for 401K contribution Catch Up
|
||||
def gen_401K_Catch_Up(wb):
|
||||
fig = make_basic_greenred_NL("401K Catch Up",wb["O Mountain"]["A8"].value,wb["O Mountain"]["C8"].value)
|
||||
|
||||
fig.savefig('./.gen/401K_Catch_Up.png',dpi=300)
|
||||
|
||||
# Generates graph for HSA Contribution
|
||||
def gen_HSA_Contribution(wb):
|
||||
fig = make_basic_greenred_NL("HSA Contribution",wb["O Mountain"]["A10"].value,wb["O Mountain"]["C10"].value)
|
||||
|
||||
fig.savefig('./.gen/HSA_Contribution.png',dpi=300)
|
||||
|
||||
# Generates graph for FSA Contribution
|
||||
def gen_FSA_Contribution(wb):
|
||||
fig = make_basic_greenred_NL("FSA Contribution",wb["O Mountain"]["A12"].value,wb["O Mountain"]["C12"].value)
|
||||
|
||||
fig.savefig('./.gen/FSA_Contribution.png',dpi=300)
|
||||
|
||||
|
||||
### Oh I Mountain
|
||||
|
||||
# Generates main Oh I Mountain Graph
|
||||
def gen_Oh_I_Mountain(wb):
|
||||
|
||||
title = "Monthly Income Goal"
|
||||
width = 0.2
|
||||
bottom = 0
|
||||
|
||||
#setup plot
|
||||
fig, ax = plt.subplots()
|
||||
fig.patch.set_facecolor((0,0,0,0))
|
||||
ax.set_facecolor((0,0,0,0))
|
||||
|
||||
#Gets values
|
||||
values = [
|
||||
[wb["Oh I Mountain"]["A6"].value,"cornflowerblue"],
|
||||
[wb["Oh I Mountain"]["B6"].value,"orange"],
|
||||
[wb["Oh I Mountain"]["C6"].value,"mediumorchid"],
|
||||
[wb["Oh I Mountain"]["D6"].value,"gold"],
|
||||
[wb["Oh I Mountain"]["E6"].value,"darkturquoise"],
|
||||
[wb["Oh I Mountain"]["F6"].value,"limegreen"],
|
||||
[wb["Oh I Mountain"]["G6"].value,"royalblue"],
|
||||
[wb["Oh I Mountain"]["C2"].value,"red"]
|
||||
]
|
||||
|
||||
for value in values:
|
||||
p = ax.bar(title, value[0], width, bottom=bottom, align='center',color=value[1])
|
||||
ax.bar_label(p, label_type='center', fmt=currency_fmt)
|
||||
bottom += value[0]
|
||||
|
||||
fig.savefig('./.gen/Monthly_Income_Goal.png',dpi=300)
|
||||
|
||||
102
main.py
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
from openpyxl import Workbook, load_workbook
|
||||
import numpy as np
|
||||
import os
|
||||
import shutil
|
||||
import graphs
|
||||
import cords
|
||||
from PIL import Image
|
||||
|
||||
|
||||
#Setup directorys
|
||||
try:
|
||||
os.mkdir('./.gen')
|
||||
os.mkdir('./gen')
|
||||
except:
|
||||
pass
|
||||
|
||||
# Generate Graphs
|
||||
wb = load_workbook('./Numbers.xlsx', data_only=True)
|
||||
graphs.gen_EF(wb)
|
||||
graphs.gen_LI(wb)
|
||||
graphs.gen_DI(wb)
|
||||
graphs.gen_Roth_IRA(wb)
|
||||
graphs.gen_Roth_Catch_Up(wb)
|
||||
graphs.gen_401K_Contribution(wb)
|
||||
graphs.gen_401K_Catch_Up(wb)
|
||||
graphs.gen_HSA_Contribution(wb)
|
||||
graphs.gen_FSA_Contribution(wb)
|
||||
graphs.gen_Oh_I_Mountain(wb)
|
||||
|
||||
|
||||
### Image Work
|
||||
|
||||
## I Mountain image code
|
||||
I_Mountain = Image.open('./templets/I_mountain.png').convert('RGBA').resize((1920, 1080))
|
||||
I_Mountain_Mask = Image.open('./templets/mask/I_mountain_mask.png').convert('L')
|
||||
blank = Image.open('./templets/I_mountain.png').convert('RGBA').resize((1920, 1080))
|
||||
|
||||
EF = Image.open('./.gen/EF.png')
|
||||
EF = cords.scale(EF,0.265)
|
||||
blank.paste(EF, cords.center_on(EF,(463,805)),EF)
|
||||
|
||||
DI = Image.open('./.gen/DI.png')
|
||||
DI = cords.scale(DI,0.265)
|
||||
blank.paste(DI, cords.center_on(DI,(698,450)),DI)
|
||||
|
||||
LI = Image.open('./.gen/LI.png')
|
||||
LI = cords.scale(LI,0.265)
|
||||
blank.paste(LI, cords.center_on(LI,(1472,802)),LI)
|
||||
|
||||
#Mask and combine
|
||||
Image.composite(blank, I_Mountain, I_Mountain_Mask).save("./gen/I_mountain.png")
|
||||
|
||||
|
||||
## O Mountain Image Code
|
||||
O_Mountain = Image.open('./templets/O_mountain.png').convert('RGBA').resize((1920, 1080))
|
||||
O_Mountain_Mask = Image.open('./templets/mask/O_mountain_mask.png').convert('L')
|
||||
O_Mountain_Mask1 = Image.open('./templets/mask/O_mountain_mask1.png').convert('L')
|
||||
O_Mountain_Mask2 = Image.open('./templets/mask/O_mountain_mask2.png').convert('L')
|
||||
blank = Image.open('./templets/O_mountain.png').convert('RGBA').resize((1920, 1080))
|
||||
blank2 = Image.new('RGBA',(1920,1080))
|
||||
|
||||
K401 = Image.open('./.gen/401K_Contribution.png')
|
||||
K401 = cords.scale(K401,0.378)
|
||||
blank.paste(K401, cords.center_on(K401,(386,806)),K401)
|
||||
|
||||
K401C = Image.open('./.gen/401K_Catch_Up.png')
|
||||
K401C = cords.scale(K401C,0.378)
|
||||
blank2.paste(K401C, cords.center_on(K401C,(557,806)),K401C)
|
||||
|
||||
IRAC = Image.open('./.gen/Roth_Catch_Up.png')
|
||||
IRAC = cords.scale(IRAC,0.265)
|
||||
blank.paste(IRAC, cords.center_on(IRAC,(1177,855)),IRAC)
|
||||
|
||||
IRA = Image.open('./.gen/Roth_IRA.png')
|
||||
IRA = cords.scale(IRA,0.265)
|
||||
blank2.paste(IRA, cords.center_on(IRA,(1425,855)),IRA)
|
||||
|
||||
# FSA = Image.open('./.gen/FSA_Contribution.png')
|
||||
# FSA = cords.scale(FSA,0.265)
|
||||
# blank2.paste(FSA, cords.center_on(FSA,(1425,855)),FSA)
|
||||
|
||||
blank2 = Image.composite(blank2, Image.new('RGBA',(1920,1080)), O_Mountain_Mask2)
|
||||
blank = Image.alpha_composite(blank,blank2)
|
||||
|
||||
#blank.save('blank.png')
|
||||
Image.composite(blank, O_Mountain, O_Mountain_Mask).save("./gen/O_mountian.png")
|
||||
|
||||
|
||||
## Oh I Mountain Image Code
|
||||
Oh_I_Mountain = Image.open('./templets/Oh_I_mountain.png').convert('RGBA').resize((1920, 1080))
|
||||
Oh_I_Mountain_Mask = Image.open('./templets/mask/Oh_I_mountain_mask.png').convert('L')
|
||||
blank = Image.open('./templets/Oh_I_mountain.png').convert('RGBA').resize((1920, 1080))
|
||||
|
||||
Goal = Image.open('./.gen/Monthly_Income_Goal.png')
|
||||
Goal = cords.scale(Goal,0.68)
|
||||
blank.paste(Goal, cords.center_on(Goal,(946,673)),Goal)
|
||||
|
||||
#Mask and combine
|
||||
Image.composite(blank, Oh_I_Mountain, Oh_I_Mountain_Mask).save("./gen/Oh_I_mountain.png")
|
||||
|
||||
#Remove directorys
|
||||
shutil.rmtree('./.gen')
|
||||
BIN
templets/I_mountain.png
Normal file
|
After Width: | Height: | Size: 205 KiB |
BIN
templets/O_mountain.png
Normal file
|
After Width: | Height: | Size: 243 KiB |
BIN
templets/Oh_I_mountain.png
Normal file
|
After Width: | Height: | Size: 145 KiB |
BIN
templets/mask/I_mountain_mask.png
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
templets/mask/O_mountain_mask.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
templets/mask/O_mountain_mask1.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
templets/mask/O_mountain_mask2.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
templets/mask/Oh_I_mountain_mask.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |