\CAsciiArt

Create an ASCII version of an image.

Summary

Methods
Properties
Constants
__construct()
addCharacterSet()
setOptions()
createFromFile()
luminanceAreaAverage()
getLuminance()
luminance2character()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$characterSet
$characters
$charCount
$scale
$luminanceStrategy
N/A

Properties

$characterSet

$characterSet : 

Character set to use.

Type

$characters

$characters : 

Current character set.

Type

$charCount

$charCount : 

Length of current character set.

Type

$scale

$scale : 

Scale of the area to swap to a character.

Type

$luminanceStrategy

$luminanceStrategy : 

Strategy to calculate luminance.

Type

Methods

__construct()

__construct() 

Constructor which sets default options.

addCharacterSet()

addCharacterSet(string  $key, string  $value) : $this

Add a custom character set.

Parameters

string $key

for the character set.

string $value

for the character set.

Returns

$this

setOptions()

setOptions(array  $options = array()) : $this

Set options for processing, defaults are available.

Parameters

array $options

to use as default settings.

Returns

$this

createFromFile()

createFromFile(string  $filename) : string

Create an Ascii image from an image file.

Parameters

string $filename

of the image to use.

Returns

string —

$ascii with the ASCII image.

luminanceAreaAverage()

luminanceAreaAverage(string  $img, integer  $x1, integer  $y1, integer  $x2, integer  $y2) : integer

Get the luminance from a region of an image using average color value.

Parameters

string $img

the image.

integer $x1

the area to get pixels from.

integer $y1

the area to get pixels from.

integer $x2

the area to get pixels from.

integer $y2

the area to get pixels from.

Returns

integer —

$luminance with a value between 0 and 100.

getLuminance()

getLuminance(integer  $red, integer  $green, integer  $blue) : float

Calculate luminance value with different strategies.

Parameters

integer $red

The color red.

integer $green

The color green.

integer $blue

The color blue.

Returns

float —

$luminance with a value between 0 and 1.

luminance2character()

luminance2character(  $luminance) : string

Translate the luminance value to a character.

Parameters

$luminance

Returns

string —

with the ascii character.