You are here

function imagick_convolve_form in Imagick 7

Settings form for the imagick convolve effect.

Parameters

$action: The saved action form parameters.

1 string reference to 'imagick_convolve_form'
imagick_image_effect_info in ./imagick.module
Implements hook_image_effect_info()

File

effects/imagick.convolve.inc, line 39

Code

function imagick_convolve_form($data) {
  $data = array_merge(imagick_convert_defaults(), (array) $data);
  if (isset($data['matrix'])) {
    $matrix_values = $data['matrix']['entries'];
  }
  else {
    $matrix_values = array_fill(0, 3, array_fill(0, 3, 1));
  }

  // kernel matrix inputs
  $form['matrix'] = array(
    '#type' => 'item',
    '#title' => t('Kernel matrix'),
    '#collapset' => FALSE,
    '#required' => TRUE,
    '#prefix' => '<div class="matrix-wrapper">',
    '#suffix' => '</div>',
    '#attached' => array(
      'css' => array(
        drupal_get_path('module', 'imagick') . '/css/convolve-matrix.css',
      ),
    ),
  );
  $form['matrix']['entries'] = array();
  for ($i = 0; $i < 3; $i++) {
    $form['matrix']['entries'][$i] = array(
      '#type' => 'fieldset',
    );
    for ($j = 0; $j < 3; $j++) {
      $form['matrix']['entries'][$i][$j] = array(
        '#type' => 'textfield',
        '#title' => t('Matrix entry') . " ({$i},{$j})",
        '#title_display' => 'invisible',
        '#default_value' => $matrix_values[$i][$j],
        '#size' => 3,
        '#required' => TRUE,
        '#element_validate' => array(
          'element_validate_number',
        ),
      );
    }
  }

  // filter label input
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Label'),
    '#description' => t('A label to identify this filter effect.'),
    '#default_value' => isset($data['label']) ? $data['label'] : '',
    '#required' => TRUE,
  );
  return $form;
}