-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo 2.py
49 lines (42 loc) · 3.39 KB
/
demo 2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
####################################################################################################
## DEMO FILE: Spider-Man ##
####################################################################################################
####################################################################################################
## THE CONCEPT ##
## ----------- ##
## ##
## Every pixel in an image has a 'greyscale' value - the darker it is, the lower the 'greyscale'. ##
## If we can use this greyscale value to choose a color from a list of our choice (let's call it ##
## SOURCE_COLORS), we can effectively 'shade' the image with cool, artistic effects. ##
## ##
## That's what this program does. ##
## ##
## Interpolation means 'finding the middle ground' (kind of). By interpolating between [black, ##
## white], we get [black, GREY, white]. By interpolating again between this, we get [black, ##
## DARK-GREY, grey, LIGHT-GREY, white], and so on. ##
## The number of interpolations, or 'INTERPOLATION_COUNT' can be whatever number you want - 0 ##
## meaning only the source colors are used, and 8 meaning infinite combinations between the ##
## SOURCE_COLORS you set. ##
## ##
## You can view / run some demo programs I made that showcase just how awesome this feature is. ##
## Above all, art is about experimentation, so have fun with it! ##
####################################################################################################
IMAGE_PATH = "Images/Spider-Man.jpg"
INTERPOLATION_COUNT = 8
VIEW_SCALE = 0.4
# SOURCE_COLORS -> As you can see in the result, the lighter colors like white become 'azure', while darker colors become 'black', and everything in between becomes 'red'. Try removing 'black' and you'll get a cool, ghostly spider man!
SOURCE_COLORS = ['black', 'red', 'azure']
SAVE_IMAGE = False
SAVE_NAME = "Spider-Man"
####################################################################################################
## WARNING: Nerdy Code Stuff ##
####################################################################################################
from Helpers.shader import *
SOURCE_COLORS = prepare_source_colors(SOURCE_COLORS)
if not SAVE_IMAGE:
sample_image = shade_image(IMAGE_PATH, INTERPOLATION_COUNT, SOURCE_COLORS, VIEW_SCALE=VIEW_SCALE)
sample_image.show()
if SAVE_IMAGE:
print(f"Saving to Generated/{SAVE_NAME}.png")
final_image = shade_image(IMAGE_PATH, INTERPOLATION_COUNT, SOURCE_COLORS, VIEW_SCALE=1)
final_image.save(f"Generated/{SAVE_NAME}.png", "PNG")