@php if (is_string($state)) { $state = json_decode($state, true); } $boxNumber = 1; @endphp @if ($state && isset($state['size'], $state['contents'])) @php $actualWidth = $state['size']['width'] ?? 800; $actualHeight = $state['size']['height'] ?? 600; $maxWidth = 200; $scale = $maxWidth / $actualWidth; $scaledWidth = $actualWidth * $scale; $scaledHeight = $actualHeight * $scale; @endphp
@foreach ($state['contents'] as $content) @php $cWidth = ($content['size']['width'] ?? 0) * $scale; $cHeight = ($content['size']['height'] ?? 0) * $scale; $cX = ($content['pos']['x'] ?? 0) * $scale; $cY = ($content['pos']['y'] ?? 0) * $scale; $origin = $content['origin'] ?? 'top-left'; $rotate = (float) ($content['rotate'] ?? 0); if ($origin === 'center') { $cX = $cX - $cWidth / 2; $cY = $cY - $cHeight / 2; } $type = $content['type'] ?? 'box'; $src = $content['src'] ?? ''; $text = $content['text'] ?? ($content['order'] ?? null); @endphp
@if ($type === 'image' && $src) @elseif($type === 'box')
{{ $text ?? $boxNumber++ }}
@endif
@endforeach
@endif