Gradient#
This style uses Unicode characters.
Example
Consider the following image:
  
 
Apple Computer [Rob Janoff, 1977]
Here's what it should look like:
 
 Procedure#
This style is implemented using the GradientDrawer.
Styling
Refer to the procedure outlined in the Styles documentation for an overview of the steps common to all styles.
Initialization#
Charset#
The charset parameter is a string containing characters ordered by their perceived brightness.
Consider the following image:
  
 
Slack
Here's what it should look like:
 
  
  
  
 Negative#
The negative parameter controls whether the charset must be reversed.
Consider the following image:
  
 
GitHub
Here's what it should look like:
 
  
 Matrices#
The charset_array attribute holds a NumPy ndarray containing all the characters in the charset.
Conversion#
Resizing#
Assuming the output text should have the dimensions text_height and text_width, the image must be resized according to the following criteria:
- image_height = text_height.
- image_width = text_width.
- If either image_heightorimage_widthis0, it is derived from the other by preserving the aspect ratio of the original image.
Following the above algorithm, each pixel of the resized image will be assigned to one character in the output text.
Source
Refer to the calculate_size function for more information.
Processing#
- The resized imageis first converted to its grayscale.
- The image matrix is normalized such that the grayscale range shifts from (0, 255)to(0, len(charset)).
- The charset_arrayis indexed with the resultant "indices" matrix, giving the finaltext_matrix.
 
 Source
Refer to the process function for more information.