function coloractions_adjustlevels_form in ImageCache Actions 8
Same name and namespace in other branches
- 7 coloractions/imagecache_coloractions.module \coloractions_adjustlevels_form()
Image effect form callback for the brightness effect.
Settings for color level adjustment actions.
Parameters
array $data: The current configuration for this image effect.
Return value
array The form definition for this effect.
1 string reference to 'coloractions_adjustlevels_form'
- imagecache_coloractions_image_effect_info in coloractions/
imagecache_coloractions.module - Implements hook_image_effect_info().
File
- coloractions/
imagecache_coloractions.module, line 840
Code
function coloractions_adjustlevels_form(array $data) {
$defaults = array(
'independent_colors' => FALSE,
'all_colors' => array(
'low' => 0,
'high' => 1,
),
'per_color' => array(
'low_red' => 0,
'high_red' => 1,
'low_green' => 0,
'high_green' => 1,
'low_blue' => 0,
'high_blue' => 1,
),
);
$data = array_merge($defaults, $data);
$form = array(
'#type' => 'container',
'help' => array(
'#type' => 'markup',
'#markup' => t("<p>Adjusting color levels scales the given channels to a range specified by the 'low' and 'high' values.\n These 'low' and 'high' values can be any value between 0 and 1.\n E.g. assume that 'low' is 0.2 and 'high' is 0.9.\n Pixels that had a value of 0, will get a value of 0.2 * 255 = 51 and pixels that had a value of 255, will get a value of 0.9 * 255 = 229.</p>\n <p>Note that color level adjustment is a mathematical filter and a such doesn't do automatic balancing.</p>"),
),
'#element_validate' => array(
'coloractions_validate_form',
),
);
$form['independent_colors'] = array(
'#type' => 'checkbox',
'#title' => t('Set each color independently'),
'#default_value' => $data['independent_colors'],
);
$form['all_colors'] = array(
'#type' => 'container',
'#tree' => TRUE,
'#title' => t('All colors range'),
'#required' => !$data['independent_colors'],
'#states' => array(
'visible' => array(
':input[name="data[independent_colors]"]' => array(
'checked' => FALSE,
),
),
'required' => array(
':input[name="data[independent_colors]"]' => array(
'checked' => FALSE,
),
),
),
);
$form['all_colors'] += coloractions_adjustlevels_form_helper(array(
'low' => array(
'title' => t('Low'),
'default' => $data['all_colors']['low'],
),
'high' => array(
'title' => t('High'),
'default' => $data['all_colors']['high'],
),
));
$form['per_color'] = array(
'#type' => 'container',
'#tree' => TRUE,
'#title' => t('Individual Color Ranges'),
'#required' => $data['independent_colors'],
'#states' => array(
'visible' => array(
':input[name="data[independent_colors]"]' => array(
'checked' => TRUE,
),
),
'required' => array(
':input[name="data[independent_colors]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['per_color'] += coloractions_adjustlevels_form_helper(array(
'low_red' => array(
'title' => t('Red Low'),
'default' => $data['per_color']['low_red'],
),
'high_red' => array(
'title' => t('Red High'),
'default' => $data['per_color']['high_red'],
),
'low_green' => array(
'title' => t('Green Low'),
'default' => $data['per_color']['low_green'],
),
'high_green' => array(
'title' => t('Green High'),
'default' => $data['per_color']['high_green'],
),
'low_blue' => array(
'title' => t('Blue Low'),
'default' => $data['per_color']['low_blue'],
),
'high_blue' => array(
'title' => t('Blue High'),
'default' => $data['per_color']['high_blue'],
),
));
return $form;
}