Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Raster\Painter;
6
7use Phpdftk\Raster\RasterSurface;
8use Phpdftk\Raster\RgbaPixel;
9use Phpdftk\Raster\BlendMode;
10
11/**
12 * Surface painter — primitive tree → pixels.
13 *
14 * Phase 4C.1 implements the concrete painter. The interface is
15 * stable from the scaffold so call sites in svg-to-pdf and
16 * html-to-pdf can be written against it now.
17 *
18 * The painter is stateful with respect to the surface (which it
19 * writes into) but stateless across primitives — each call is a
20 * self-contained drawing op. Caller manages the graphics-state
21 * stack at the translator layer.
22 */
23interface PainterInterface
24{
25    /**
26     * Fill a path defined by a sequence of PDF-style path operators
27     * (`m`, `l`, `c`, `v`, `y`, `h`) plus the SVG arc-to-cubic
28     * conversion svg-to-pdf already does. The fill colour is
29     * applied to all pixels inside the winding-rule-determined
30     * interior.
31     *
32     * @param list<array{op: string, args: list<float>}> $path
33     */
34    public function fillPath(array $path, RgbaPixel $fill, string $fillRule = 'nonzero'): void;
35
36    /**
37     * Stroke a path with the given colour and width. Stroke
38     * geometry (linecap, linejoin, dasharray) follows the SVG /
39     * CSS conventions.
40     *
41     * @param list<array{op: string, args: list<float>}> $path
42     */
43    public function strokePath(array $path, RgbaPixel $stroke, float $width): void;
44
45    /**
46     * Composite another surface onto this one at `(x, y)` with the
47     * given blend mode. Source-over by default — the standard
48     * Porter-Duff "src over dst" rule. Other blend modes go through
49     * the CSS Compositing 1 / 2 math (4C.2).
50     */
51    public function compositeSurface(
52        RasterSurface $source,
53        int $x,
54        int $y,
55        BlendMode $blendMode = BlendMode::Normal,
56    ): void;
57}