function SvgIconBuilder::getOffset

Same name in other branches
  1. 9 core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php \Drupal\Core\Layout\Icon\SvgIconBuilder::getOffset()
  2. 8.9.x core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php \Drupal\Core\Layout\Icon\SvgIconBuilder::getOffset()
  3. 11.x core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php \Drupal\Core\Layout\Icon\SvgIconBuilder::getOffset()

Gets the offset for this region.

Parameters

int $delta: The zero-based delta of the region.

int $length: The height or width of the region.

int $stroke_width: The width of the region borders.

int $padding: The padding between regions.

Return value

int The offset for this region.

1 call to SvgIconBuilder::getOffset()
SvgIconBuilder::calculateSvgValues in core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php
Calculates the dimensions and offsets of all regions.

File

core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php, line 205

Class

SvgIconBuilder
Builds SVG layout icons.

Namespace

Drupal\Core\Layout\Icon

Code

protected function getOffset($delta, $length, $stroke_width, $padding) {
    // Half of the stroke width is drawn outside the dimensions.
    $stroke_width /= 2;
    // For every region in front of this add two strokes, as well as one
    // directly in front.
    $num_of_strokes = 2 * $delta + 1;
    return $num_of_strokes * $stroke_width + $delta * ($length + $padding);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.