protected function renderForeground(
        \Jdenticon\Rendering\RendererInterface $renderer, 
        \Jdenticon\Rendering\Rectangle $rect,
        \Jdenticon\IdenticonStyle $style, 
        \Jdenticon\Rendering\ColorTheme $colorTheme, 
        $hash)
    {
        // Ensure rect is quadratic and a multiple of the cell count
        $normalizedRect = $this->normalizeRectangle($rect);
        $cellSize = $normalizedRect->width / $this->getCellCount();

        foreach ($this->getShapes($colorTheme, $hash) as $shape) {
            $rotation = $shape->startRotationIndex;
            
            $renderer->beginShape($shape->color);
            
            $positionCount = count($shape->positions);
            for ($i = 0; $i + 1 < $positionCount; $i += 2) {
                $renderer->setTransform(new Transform(
                    $normalizedRect->x + $shape->positions[$i + 0] * $cellSize,
                    $normalizedRect->y + $shape->positions[$i + 1] * $cellSize,
                    $cellSize, $rotation++ % 4));

                $shape->definition->__invoke($renderer, $cellSize, $i / 2);
            }
            
            $renderer->endShape();
        }
    }