RANDOM ART
Personal coding project, responsible for all
Software: Python
This program is using skeleton Python to generate random art images, all users can generate images based on the input of numbers, resolutions, and levels of recursion (figure 0.0).
![]() | ![]() | ![]() |
---|---|---|
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
Figure 0.0 Random Art
Technical Breakdown
Step1 Basic settings
-
import PIL, sin, cos, tan, sqrt, pi, radians, random, math, os.
-
Define the evalExpr function that evaluates the string that is sent to it.
-
Define poltIntensity to return a grayscale image of the given function.
-
Define the plotColor function that returns an image constructed from the plotIntensity function (figure 1.0).

Figure 1.0 Basic settings
Step 2 Expressions
Define the buildExpr function to produce random expressions that are suitable for passing to eval Expr, random values will be taken from the list and constitute a range of expressions (figure 2.0).



Figure 2.0 Expressions
Step 3 Gray & Color Functions (figure 3.0)
-
Define the makeGray function to generate gray images files named grayImage_0.png, grayImage_1.png
-
Define the makeColor function to generate color images files named colorImage_0.png, colorImage_1.png

Figure 3.0 Gray and Color function
Step 4 High Resolution
Define the recreateImage function that allows users to create images with higher resolution, all expressions are saved in .txt files, users can choose to read these files and generate images with higher resolution (figure 4.0).

Figure 4.0 Recreate images with higher resolution
Step 5 Create Folders & Rename
Once start the program, three folders will be created and save images, images with higher resolutions, and txt files respectively.
If these folders already exist, they will be renamed with an index to get rid of errors, three new folders will be created without an index.
Define the rename function that allows users to rename files in folders created.

Figure 5.0 Create folders and rename images
Step 6 Main
The main function calls other functions inside to generate a bunch of random grayscale and color pictures (figure 6.0).

Figure 6.0 Main function
Workflow
# Description:
# This program is using skeleton Python to generate random art images
# The program firstly renames existing folders to get rid of errors and coverage,
# Then it allows users to generate random gray & color images
# For each category of images, users should follow three steps:
# step1: input the number of images
# step2: input the resolution
# step3: input the levels of recursion
# Gray and color images are allowed to recreate with higher resolution
# Additionally, users are allowed to rename all of the images they created
#
# Date: May 8, 2022
# Authour: Yachan Yuan
# Adapted by Chris Stone from code by Andrew Farmer
# From Nifty Assignments 6/24/2018
# Further adapted by Deborah R. Fowler (comments annotated DRF)
# 4/19/2020 - changed print statements suitable for 3.6
#
# Input: Numbers, resolutions, and recursion levels of images
# Output: Png files of gray and color images with original or higher resolution, txt files