You are here

function canvasactions_roundedcorners_form in ImageCache Actions 5.2

Same name and namespace in other branches
  1. 8 canvasactions/rounded_corners.inc \canvasactions_roundedcorners_form()
  2. 5.3 canvasactions.inc \canvasactions_roundedcorners_form()
  3. 6.2 canvasactions/rounded_corners.inc \canvasactions_roundedcorners_form()
  4. 6 canvasactions.inc \canvasactions_roundedcorners_form()
  5. 7 canvasactions/rounded_corners.inc \canvasactions_roundedcorners_form()

Set radius for corner rounding

Implementation of imagecache_hook_form()

Parameters

$action array of settings for this action:

Return value

a form definition

File

./canvasactions.inc, line 420

Code

function canvasactions_roundedcorners_form($action) {
  if (imageapi_default_toolkit() != 'imageapi_gd') {
    drupal_set_message('Rounded corners are not currently supported by using imagemagick. This effect requires GD image toolkit only.', 'warning');
  }
  drupal_add_js(drupal_get_path('module', 'imagecache_canvasactions') . '/imagecache_actions.jquery.js');
  $defaults = array(
    'radius' => '16',
    'antialias' => TRUE,
    'independent_corners_set' => array(
      'independent_corners' => FALSE,
      'radii' => array(
        'tl' => 0,
        'tr' => 0,
        'bl' => 0,
        'br' => 0,
      ),
    ),
  );
  $action = array_merge($defaults, (array) $action);
  $form['radius'] = array(
    '#type' => 'textfield',
    '#title' => t('radius'),
    '#default_value' => $action['radius'],
    '#size' => 2,
  );
  $form['independent_corners_set'] = array(
    '#type' => 'fieldset',
    '#title' => t('Individual Corner Values'),
    '#collapsible' => TRUE,
    '#collapsed' => !$action['independent_corners_set']['independent_corners'],
  );
  $form['independent_corners_set']['independent_corners'] = array(
    '#type' => 'checkbox',
    '#title' => t('Set Corners Independently'),
    '#default_value' => $action['independent_corners_set']['independent_corners'],
  );
  $corners = array(
    'tl' => t("Top Left Radius"),
    'tr' => t("Top Right Radius"),
    'bl' => t("Bottom Left Radius"),
    'br' => t("Bottom Right Radius"),
  );

  // Loop over the four corners and create field elements for them.
  $form['independent_corners_set']['radii'] = array(
    '#type' => 'item',
  );
  foreach ($corners as $attribute => $label) {
    $form['independent_corners_set']['radii'][$attribute] = array(
      '#type' => 'textfield',
      '#title' => $label,
      '#default_value' => 0 + $action['independent_corners_set']['radii'][$attribute],
      '#size' => 2,
    );
  }
  $form['antialias'] = array(
    '#type' => 'checkbox',
    '#title' => t('antialias'),
    '#return_value' => TRUE,
    '#default_value' => $action['antialias'],
    '#description' => t('Attempt antialias smoothing when drawing the corners'),
  );
  $form['notes'] = array(
    '#type' => 'markup',
    '#value' => t('
        Note: the rounded corners effect uses true alpha transparency masking.
        This means that this effect <b>will fail to be saved</b> on jpegs
        <em>unless</em> you either <ul>
        <li>convert the image to PNG (using the coloractions filter for that),</li>
        <li>underlay a solid color (using coloractions-alpha-flatten) or</li>
        <li>underlay a background image (canvasactions-underlay)</li>
        </ul>
        as a later part of this imagecache pipeline.
        <br/>
      '),
  );
  return $form;
}