3 Commits

Author SHA1 Message Date
npease 02895d82d8 Final
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
2022-12-08 21:08:18 -05:00
npease 970ab3f721 Updated Config, Added Extra Credit to Project Code/main.py
continuous-integration/drone/push Build is passing
2022-12-01 13:59:18 -05:00
npease 55a0892960 Forgot to Remove seed from config of release
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2022-12-01 13:05:27 -05:00
25 changed files with 137 additions and 48 deletions
Binary file not shown.
Binary file not shown.
+8 -3
View File
@@ -6,15 +6,20 @@ Required modules: graphics.py, config.py
## Variables
|Type|Data Type|Name|Scope|Description|Default Value|
|----|---------|----|-----|-------|------------|
|CONSTANT|str|PRESET_NAME|Global*|Name of preset to be loaded|
|CONSTANT|bool|VERBOSE_MODE|Global*|Enables or disables verbose logging to console|False
|CONSTANT|int|WINDOW_WIDTH|Global*|Width of the window for the display (in pixels)|600|
|CONSTANT|int|WINDOW_HEIGHT|Global*|Height of the window for the display (in pixels)|600|
|CONSTANT|int|LOWER_SPLIT_BOUND|Global*|Minimum width and height of all rectangles|90|
|CONSTANT|float|REGION_MULTIPLIER|Global*|Value to multiply region size by to determine random split|1.5|
|CONSTANT|int|SPLIT_POINT_LOWER_PERCENTAGE|Global*|Lower percentage of split point position in region|38|
|CONSTANT|int|SPLIT_POINT_UPPER_PERCENTAGE|Global*|Upper percentage of split point position in region|38|
|CONSTANT|float|YELLOW_CUTOFF|Global*|Cutoff for Yellow in fillRegion()|0.9|
|CONSTANT|float|BLUE_CUTOFF|Global*|Cutoff for Blue in fillRegion()|0.15|
|CONSTANT|float|RED_CUTOFF|Global*|Cutoff for Red in fillRegion()|0.25|
|CONSTANT|float|COLOR1_CUTOFF|Global*|Cutoff for COLOR1 in fillRegion()|0.9|
|CONSTANT|str|COLOR1_COLOR|Global*|Color for COLOR1 used for fill|yellow|
|CONSTANT|float|COLOR2_CUTOFF|Global*|Cutoff for COLOR2 in fillRegion()|0.15|
|CONSTANT|str|COLOR2_COLOR|Global*|Color for COLOR2 used for fill|blue|
|CONSTANT|float|COLOR3_CUTOFF|Global*|Cutoff for COLOR3 in fillRegion()|0.25|
|CONSTANT|str|COLOR3_COLOR|Global*|Color for COLOR3 used for fill|red|
|CONSTANT|int|REGION_WIDTH_LOWER|Global|Denotes lower width bound of ```current_bounds[list]``` index value|0|
|CONSTANT|int|REGION_WIDTH_UPPER|Global|Denotes upper width bound of ```current_bounds[list]``` index value|2|
|CONSTANT|int|REGION_HEIGHT_LOWER|Global|Denotes lower height bound of ```current_bounds[list]``` index value|1|
@@ -9,7 +9,6 @@
# I collaborated with no one on this project
from graphics import *
from config import * # MOST CONSTANTS ARE IN CONFIG.PY FOR EASY SETTINGS RECALL AND USABILITY
# these are to make my list structures easier to recall, may be removed after design
@@ -91,12 +90,12 @@ def fillRegion(current_bounds, draw_window):
r = random.random()
temp_rect = Rectangle(Point(current_bounds[REGION_WIDTH_LOWER],current_bounds[REGION_HEIGHT_LOWER]), Point(current_bounds[REGION_WIDTH_UPPER],current_bounds[REGION_HEIGHT_UPPER]))
temp_rect.setOutline("black")
if r < BLUE_CUTOFF:
fill_color = "blue"
elif r < RED_CUTOFF:
if r < COLOR3_CUTOFF:
fill_color = "yellow"
elif r < COLOR2_CUTOFF:
fill_color = "blue"
elif r < COLOR1_CUTOFF:
fill_color = "red"
elif r < YELLOW_CUTOFF:
fill_color = "yellow"
else:
fill_color = "white"
temp_rect.setFill(fill_color)
@@ -9,8 +9,6 @@ SPLIT_POINT_UPPER_PERCENTAGE = 68
# fill constants
# cutoffs are randomly generates percentages in the range 0 - 0.99
YELLOW_CUTOFF = 0.9
BLUE_CUTOFF = 0.15
RED_CUTOFF = 0.25
random.seed(8675309)
COLOR1_CUTOFF = 0.25
COLOR2_CUTOFF = 0.15
COLOR3_CUTOFF = 0.09
@@ -1,4 +1,4 @@
# File: Pease-p2.py
# File: Pease-p2-xc.py
# Author: PEASE, NICHOLAS
# Date: 29 NOV 2022
# Section: 1002-LAB
@@ -9,7 +9,6 @@
# I collaborated with no one on this project
from graphics import *
from config import * # MOST CONSTANTS ARE IN CONFIG.PY FOR EASY SETTINGS RECALL AND USABILITY
# these are to make my list structures easier to recall, may be removed after design
@@ -19,8 +18,12 @@ REGION_HEIGHT_LOWER = 2
REGION_HEIGHT_UPPER = 3
def main():
draw_window = GraphWin("Result", WINDOW_WIDTH, WINDOW_HEIGHT)
print("Piet Mondrian Painting Generator v.1\nTo adjust program parameters, edit config.py or rename the other supplied configs as config.py.")
print("Config File Loaded: "+PRESET_NAME)
print("Beginning Generation...")
draw_window = GraphWin("Result", WINDOW_WIDTH, WINDOW_HEIGHT, autoflush=False)
canvasSplitLogic([0,WINDOW_WIDTH,0,WINDOW_HEIGHT],draw_window) # initial split, recursion until complete split
update()
draw_window.getMouse()
draw_window.close()
@@ -30,12 +33,14 @@ def canvasSplitLogic(current_bounds,draw_window):
region_height = current_bounds[REGION_HEIGHT_UPPER] - current_bounds[REGION_HEIGHT_LOWER]
if region_width > (WINDOW_WIDTH // 2):
# SPLIT ONLY WIDTH ALWAYS
print("TOO WIDE, AUTOSPLIT")
if VERBOSE_MODE:
print("TOO WIDE, AUTOSPLIT")
splitCurrentBoundWidth(current_bounds, draw_window)
elif region_height > (WINDOW_HEIGHT // 2):
# SPLIT ONLY HEIGHT ALWAYS
print("TOO TALL, AUTOSPLIT")
if VERBOSE_MODE:
print("TOO TALL, AUTOSPLIT")
splitCurrentBoundHeight(current_bounds, draw_window)
elif region_width <= (WINDOW_WIDTH // 2) and region_width > LOWER_SPLIT_BOUND:
@@ -43,37 +48,44 @@ def canvasSplitLogic(current_bounds,draw_window):
r = random.randint(LOWER_SPLIT_BOUND,int(region_width*REGION_MULTIPLIER))
if r < region_width:
# SPLIT REGION
print("RANDOMLY DECIDED TO SPLIT WIDTH")
if VERBOSE_MODE:
print("RANDOMLY DECIDED TO SPLIT WIDTH")
splitCurrentBoundWidth(current_bounds, draw_window)
elif region_height <= (WINDOW_HEIGHT // 2) and region_height > LOWER_SPLIT_BOUND:
# RANDOMLY DECIDE TO SPLIT AT RANDOMLY CHOSEN LOCATION (HEIGHT)
r = random.randint(LOWER_SPLIT_BOUND,int(region_height*REGION_MULTIPLIER))
if r < region_height:
# SPLIT ONLY HEIGHT ALWAYS
print("DID NOT SPLIT WIDTH, RANDOMLY DECIDED TO SPLIT HEIGHT")
if VERBOSE_MODE:
print("DID NOT SPLIT WIDTH, RANDOMLY DECIDED TO SPLIT HEIGHT")
splitCurrentBoundHeight(current_bounds, draw_window)
else:
print("DID NOT SPLIT WIDTH OR HEIGHT")
if VERBOSE_MODE:
print("DID NOT SPLIT WIDTH OR HEIGHT")
elif region_height <= (WINDOW_HEIGHT // 2) and region_height > LOWER_SPLIT_BOUND:
# RANDOMLY DECIDE TO SPLIT AT RANDOMLY CHOSEN LOCATION (HEIGHT)
r = random.randint(LOWER_SPLIT_BOUND,int(region_height*REGION_MULTIPLIER))
if r < region_height:
# SPLIT ONLY HEIGHT ALWAYS
print("RANDOMLY DECIDED TO SPLIT HEIGHT")
if VERBOSE_MODE:
print("RANDOMLY DECIDED TO SPLIT HEIGHT")
splitCurrentBoundHeight(current_bounds, draw_window)
elif region_width <= (WINDOW_WIDTH // 2) and region_width > LOWER_SPLIT_BOUND:
# RANDOMLY DECIDE TO SPLIT AT RANDOMLY CHOSEN LOCATION (WIDTH)
r = random.randint(LOWER_SPLIT_BOUND,int(region_width*REGION_MULTIPLIER))
if r < region_width:
# SPLIT REGION
print("DID NOT SPLIT HEIGHT, RANDOMLY DECIDED TO SPLIT WIDTH")
if VERBOSE_MODE:
print("DID NOT SPLIT HEIGHT, RANDOMLY DECIDED TO SPLIT WIDTH")
splitCurrentBoundWidth(current_bounds, draw_window)
else:
print("DID NOT SPLIT WIDTH OR HEIGHT")
if VERBOSE_MODE:
print("DID NOT SPLIT WIDTH OR HEIGHT")
else:
fillRegion(current_bounds,draw_window)
print("FILL REGION ELSE")
if VERBOSE_MODE:
print("FILL REGION ELSE")
def splitCurrentBoundWidth(current_bounds, draw_window):
region_width = current_bounds[REGION_WIDTH_UPPER] - current_bounds[REGION_WIDTH_LOWER]
@@ -102,12 +114,12 @@ def fillRegion(current_bounds, draw_window):
r = random.random()
temp_rect = Rectangle(Point(current_bounds[REGION_WIDTH_LOWER],current_bounds[REGION_HEIGHT_LOWER]), Point(current_bounds[REGION_WIDTH_UPPER],current_bounds[REGION_HEIGHT_UPPER]))
temp_rect.setOutline("black")
if r < BLUE_CUTOFF:
fill_color = "blue"
elif r < RED_CUTOFF:
fill_color = "red"
elif r < YELLOW_CUTOFF:
fill_color = "yellow"
if r < COLOR3_CUTOFF:
fill_color = COLOR3_COLOR
elif r < COLOR2_CUTOFF:
fill_color = COLOR2_COLOR
elif r < COLOR1_CUTOFF:
fill_color = COLOR1_COLOR
else:
fill_color = "white"
temp_rect.setFill(fill_color)
+28
View File
@@ -0,0 +1,28 @@
import random
WINDOW_WIDTH = 600 # pixels
WINDOW_HEIGHT = 600 # pixels
LOWER_SPLIT_BOUND = 90 # as given
REGION_MULTIPLIER = 1.5 # as given
SPLIT_POINT_LOWER_PERCENTAGE = 31
SPLIT_POINT_UPPER_PERCENTAGE = 68
# fill constants
# cutoffs are randomly generated (or given) percentages in the range 0 - 0.99
# colors are the colors to be used
# is is benificial to start with the lowest probability and go to the highest probability
COLOR1_CUTOFF = 0.25
COLOR1_COLOR = "red"
COLOR2_CUTOFF = 0.15
COLOR2_COLOR = "blue"
COLOR3_CUTOFF = 0.09
COLOR3_COLOR = "yellow"
# Below are additional configuration options for the extra credit portion of this assignment
# This config file will load properly on both versions of the software, however the below options will only
# make changes on the extra credit assignment
#
# For instructions on usage, refer to README.md or to the comments provided
PRESET_NAME = "Seeded Config ('Jenny' seed)"
VERBOSE_MODE = False # Enables verbose console logging
random.seed(8675309) # This is the seed I found made a cool image and that I have embed in a png and HTML format.
+28
View File
@@ -0,0 +1,28 @@
import random
WINDOW_WIDTH = 600 # pixels
WINDOW_HEIGHT = 600 # pixels
LOWER_SPLIT_BOUND = 50 # as given
REGION_MULTIPLIER = 1.5 # as given
SPLIT_POINT_LOWER_PERCENTAGE = 21
SPLIT_POINT_UPPER_PERCENTAGE = 98
# fill constants
# cutoffs are randomly generated (or given) percentages in the range 0 - 0.99
# colors are the colors to be used
# is is benificial to start with the lowest probability and go to the highest probability
COLOR1_CUTOFF = 0.25
COLOR1_COLOR = "red"
COLOR2_CUTOFF = 0.15
COLOR2_COLOR = "blue"
COLOR3_CUTOFF = 0.09
COLOR3_COLOR = "yellow"
# Below are additional configuration options for the extra credit portion of this assignment
# This config file will load properly on both versions of the software, however the below options will only
# make changes on the extra credit assignment
#
# For instructions on usage, refer to README.md or to the comments provided
PRESET_NAME = "Default Config"
VERBOSE_MODE = False # Enables verbose console logging
#random.seed(8675309) # This is the seed I found made a cool image and that I have embed in a png and HTML format.
+8
View File
@@ -0,0 +1,8 @@
<html>
<style>
img {width:100%;height:100%;}
</style>
<body>
<img src="image1.png">
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+8
View File
@@ -0,0 +1,8 @@
<html>
<style>
img {width:100%;height:100%;}
</style>
<body>
<img src="image2.png">
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

+8
View File
@@ -0,0 +1,8 @@
<html>
<style>
img {width:100%;height:100%;}
</style>
<body>
<img src="image3.png">
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

+11
View File
@@ -0,0 +1,11 @@
Pease, Nicholas
Project 2
The directory Base Assignment contains all the files (baring the interperter) that you would need to execute my project
The directory Extra Credit contains all the files (baring the interperter) that you would need to execute the extra credit portion of my project
Images contains the png/html formats of the submissable files
* NOTE: there are 2 config files in Extra Credit, the config-image1 file contains the seed and settings to replicate the image. To use just rename to config.py and execute Pease-p2-xc.py
Binary file not shown.
Binary file not shown.
-16
View File
@@ -1,16 +0,0 @@
import random
WINDOW_WIDTH = 600 # pixels
WINDOW_HEIGHT = 600 # pixels
LOWER_SPLIT_BOUND = 90 # as given
REGION_MULTIPLIER = 1.5 # as given
SPLIT_POINT_LOWER_PERCENTAGE = 31
SPLIT_POINT_UPPER_PERCENTAGE = 68
# fill constants
# cutoffs are randomly generates percentages in the range 0 - 0.99
YELLOW_CUTOFF = 0.9
BLUE_CUTOFF = 0.15
RED_CUTOFF = 0.25
random.seed(8675309)