Functions

Convert CSS colour tokens into an expression tree.

_parse_css_colour_expression(array $tokens) : \?array

Parameters

$tokens

array

Tokens.

Returns

\?arrayExpression tree (NULL: error).

Augment an array of CSS colours with colours that are derived actually inside the CSS-sheets.

calculate_dynamic_css_colours(array $colours, \ID_TEXT $source_theme) : array

Parameters

$colours

array

Map of colours.

$source_theme

\ID_TEXT

The theme it's being generated from

Returns

arrayA pair: extended map of colours, colour expression landscape

Calculate some component relating to a theme from a colour seed.

calculate_theme(string $seed, \ID_TEXT $source_theme, \ID_TEXT $algorithm, \ID_TEXT $show, \?boolean $dark, \?array $colours, \?array $landscape, \?LANGUAGE_NAME $lang) : mixed

set equations hsv

Parameters

$seed

string

Colour seed.

$source_theme

\ID_TEXT

The theme it's being generated from

$algorithm

\ID_TEXT

The algorithm to use

$show

\ID_TEXT

What to generate ('colours', or the name of a theme image).

$dark

\?boolean

Whether it will be a dark theme (NULL: autodetect).

$colours

\?array

The colour map to use (NULL: compute).

$landscape

\?array

The computed colour landscape to use (NULL: compute).

$lang

\?LANGUAGE_NAME

The language to work in (NULL: default).

Returns

mixedImage resource OR A pair: extended map of colours, colour expression landscape

Execute CSS colour expression.

execute_css_colour_expression(mixed $expression, array $colours) : \?string

Parameters

$expression

mixed

Expression tree (array) OR leaf (string).

$colours

array

Known colours at this point.

Returns

\?stringRRGGBB colour or possibly just a number (NULL: answer cannot be computed).

Find whether a theme is dark.

find_theme_dark(\ID_TEXT $theme) : boolean

Parameters

$theme

\ID_TEXT

The theme name

Returns

booleanWhether the theme is dark

Called by find_theme_image to allow on-the-fly previewing of what theme wizard output would look like.

find_theme_image_themewizard_preview(\ID_TEXT $id) : \?URLPATH

Parameters

$id

\ID_TEXT

The theme image ID

Returns

\?URLPATHURL to image (NULL: use standard one, this one is not theme wizard influenced).

Find the seed of a theme.

find_theme_seed(\ID_TEXT $theme, boolean $no_easy_anchor) : \ID_TEXT

Parameters

$theme

\ID_TEXT

The theme name

$no_easy_anchor

boolean

Whether we can't assume the theme has any ocPortal default colour information defined, if not in theme.ini

Returns

\ID_TEXTThe seed colour

Make sure a colour component fits within the necessary range (0<=x<256).

fix_colour(mixed $x, boolean $hue) : integer

Parameters

$x

mixed

Colour component (float or integer).

$hue

boolean

Whether this is hue (meaning it cycles around)

Returns

integerConstrained colour component.

Generate a gradient for a theme.

generate_gradient(string $top, string $bottom) : resource

Parameters

$top

string

Colour for the top.

$bottom

string

Colour for the bottom.

Returns

resourceThe image

Generate a theme image by converting an existing one to a new colour scheme via intelligent blending correlation.

generate_recoloured_image(mixed $path, string $colour_a_orig, string $colour_a_new, string $colour_b1_orig, string $colour_b1_new, \?string $colour_b2_orig, \?string $colour_b2_new, string $gradient_direction, \?array $pixel_x_start_array, integer $gradient_offset, boolean $end_array) : resource

set vertical horizontal

Parameters

$path

mixed

The image path OR a preloaded GD image resource

$colour_a_orig

string

The colour code of what we have as our "minor" colour (often a border colour)

$colour_a_new

string

The colour code of what we want as our "minor" colour (often a border colour)

$colour_b1_orig

string

The colour code of what we have as our first major colour (often the only major colour)

$colour_b1_new

string

The colour code of what we want as our first major colour (often the only major colour)

$colour_b2_orig

\?string

The colour code of what we have as our second major colour (the gradient target, at the bottom/right of the image) (NULL: not gradiented)

$colour_b2_new

\?string

The colour code of what we want as our second major colour (the gradient target, at the bottom/right of the image) (NULL: not gradiented)

$gradient_direction

string

The directional code for the gradient

$pixel_x_start_array

\?array

An array that is used to limit where we do our conversion on. It specifies, for each y-offset, the x-offset we start from (NULL: no such limitation)

$gradient_offset

integer

What the gradient assumed start-position will be offset by (in the gradient direction).

$end_array

boolean

Whether the pixel_x_start array is actually an end array.

Returns

resourceThe image

Convert HSV colour components to an RGB colour.

hsv_to_rgb(float $h, float $s, float $v) : string

Based on publically distributed code fragments which were themselves based on others: reasonably assumed as public domain.

Parameters

$h

float

H component

$s

float

S component

$v

float

V component

Returns

stringRGB colour.

Standard code module initialisation function.

init__themewizard() 

Given a source theme name, configure the theme wizard for theme generation from it.

load_themewizard_params_from_theme(\ID_TEXT $theme, boolean $guess_images_if_needed) 

Parameters

$theme

\ID_TEXT

The theme name

$guess_images_if_needed

boolean

Whether we suspect the theme might not be well defined

Make a theme.

make_theme(string $themename, \ID_TEXT $source_theme, \ID_TEXT $algorithm, string $seed, boolean $use, \?boolean $dark, boolean $inherit_css) 

Note that this will trigger the AFM.

set equations hsv

Parameters

$themename

string

Name of the theme.

$source_theme

\ID_TEXT

The theme it's being generated from

$algorithm

\ID_TEXT

The algorithm to use

$seed

string

Seed colour to use.

$use

boolean

Whether to use the theme immediately.

$dark

\?boolean

Whether it will be a dark theme (NULL: autodetect).

$inherit_css

boolean

Whether to inherit the CSS, for easier theme upgrading.

Convert a textual CSS colour expression into an expression tree.

parse_css_colour_expression(string $textual) : \?array

Parameters

$textual

string

Textual expression.

Returns

\?arrayExpression tree (NULL: not real).

Generate a theme image by converting an existing one to a new colour scheme via re-hueing.

re_hue_image(mixed $path, string $seed, \ID_TEXT $source_theme, boolean $also_s_and_v, boolean $invert) : resource

Parameters

$path

mixed

The image path OR a preloaded GD image resource

$seed

string

The colour code of our hue

$source_theme

\ID_TEXT

The theme this is being generated from

$also_s_and_v

boolean

Whether to also adjust the S and V components

$invert

boolean

Whether to invert the colours

Returns

resourceThe image

Convert an RGB colour to HSV colour components.

rgb_to_hsv(string $rgb) : array

Based on publically distributed code fragments which were themselves based on others: reasonably assumed as public domain.

Parameters

$rgb

string

RRGGBB colour.

Returns

arrayTriplet of (0-255) components: H, S, V

Rewrite some CSS code according to a CSS landscape.

theme_wizard_colours_to_css(string $contents, array $landscape, \ID_TEXT $source_theme, \ID_TEXT $algorithm, \ID_TEXT $seed) : string

set equations hsv

Parameters

$contents

string

CSS to apply to.

$landscape

array

The colour expression landscape which we'll make substitutions using.

$source_theme

\ID_TEXT

The theme this is being generated from

$algorithm

\ID_TEXT

The algorithm to use

$seed

\ID_TEXT

The seed colour

Returns

stringThe sheet

Rewrite some CSS code according to a CSS landscape.

theme_wizard_colours_to_sheet(\ID_TEXT $sheet, array $landscape, \ID_TEXT $source_theme, \ID_TEXT $algorithm, \ID_TEXT $seed) : string

set equations hsv

Parameters

$sheet

\ID_TEXT

CSS filename of source file.

$landscape

array

The colour expression landscape which we'll make substitutions using.

$source_theme

\ID_TEXT

The theme this is being generated from

$algorithm

\ID_TEXT

The algorithm to use

$seed

\ID_TEXT

The seed colour

Returns

stringThe sheet

Output a theme component straight to the browser.

themewizard_script()