| 1 | package PDF::Make::Canvas; | ||
| 2 | |||
| 3 | 61 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 61 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 61 | our $VERSION = '0.15'; | |
| 7 | |||
| 8 | # Load the XS code from PDF::Make | ||
| 9 | 61 | ▶ | use PDF::Make (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | # XS bindings provide all PDF content stream operators: | ||
| 12 | # | ||
| 13 | # Graphics State Operators: | ||
| 14 | # q() - save graphics state | ||
| 15 | # Q() - restore graphics state | ||
| 16 | # cm(a,b,c,d,e,f) - concatenate matrix | ||
| 17 | # w(width) - set line width | ||
| 18 | # J(cap) - set line cap style | ||
| 19 | # j(join) - set line join style | ||
| 20 | # M(miter) - set miter limit | ||
| 21 | # d([array], phase) - set dash pattern | ||
| 22 | # ri(intent) - set rendering intent | ||
| 23 | # i(flatness) - set flatness tolerance | ||
| 24 | # gs(name) - set graphics state dict | ||
| 25 | # | ||
| 26 | # Path Construction: | ||
| 27 | # m(x,y) - move to | ||
| 28 | # l(x,y) - line to | ||
| 29 | # c(x1,y1,x2,y2,x3,y3) - cubic Bézier curve | ||
| 30 | # v(x2,y2,x3,y3) - cubic Bézier (first control = current) | ||
| 31 | # y(x1,y1,x3,y3) - cubic Bézier (second control = endpoint) | ||
| 32 | # re(x,y,w,h) - rectangle | ||
| 33 | # h() - close subpath | ||
| 34 | # | ||
| 35 | # Path Painting: | ||
| 36 | # S() - stroke | ||
| 37 | # s() - close and stroke | ||
| 38 | # f() - fill (non-zero) | ||
| 39 | # f_star() - fill (even-odd) | ||
| 40 | # B() - fill and stroke (non-zero) | ||
| 41 | # B_star() - fill and stroke (even-odd) | ||
| 42 | # b() - close, fill, and stroke (non-zero) | ||
| 43 | # b_star() - close, fill, and stroke (even-odd) | ||
| 44 | # n() - end path (no-op) | ||
| 45 | # | ||
| 46 | # Clipping: | ||
| 47 | # W() - clip (non-zero) | ||
| 48 | # W_star() - clip (even-odd) | ||
| 49 | # | ||
| 50 | # Color: | ||
| 51 | # CS(name) - set stroke color space | ||
| 52 | # cs(name) - set fill color space | ||
| 53 | # G(gray) - set stroke gray | ||
| 54 | # g(gray) - set fill gray | ||
| 55 | # RG(r,g,b) - set stroke RGB | ||
| 56 | # rg(r,g,b) - set fill RGB | ||
| 57 | # K(c,m,y,k) - set stroke CMYK | ||
| 58 | # k(c,m,y,k) - set fill CMYK | ||
| 59 | # | ||
| 60 | # Text: | ||
| 61 | # BT() - begin text object | ||
| 62 | # ET() - end text object | ||
| 63 | # Tc(space) - set character spacing | ||
| 64 | # Tw(space) - set word spacing | ||
| 65 | # Tz(scale) - set horizontal scaling | ||
| 66 | # TL(leading) - set leading | ||
| 67 | # Tf(font,size) - set font | ||
| 68 | # Tr(render) - set render mode | ||
| 69 | # Ts(rise) - set rise | ||
| 70 | # Td(tx,ty) - move text position | ||
| 71 | # TD(tx,ty) - move text position, set leading | ||
| 72 | # Tm(a,b,c,d,e,f) - set text matrix | ||
| 73 | # T_star() - move to next line | ||
| 74 | # Tj(text) - show text | ||
| 75 | # TJ(array) - show text with positioning | ||
| 76 | # quote(text) - move to next line and show text | ||
| 77 | # dquote(aw,ac,text) - set spacing, move, show | ||
| 78 | # | ||
| 79 | # XObject: | ||
| 80 | # Do(name) - invoke XObject | ||
| 81 | # | ||
| 82 | # Inline Image: | ||
| 83 | # BI() - begin inline image | ||
| 84 | # ID($data) - image data | ||
| 85 | # EI() - end inline image | ||
| 86 | # | ||
| 87 | # Marked Content: | ||
| 88 | # BMC(tag) - begin marked content | ||
| 89 | # BDC(tag,props) - begin marked content with properties | ||
| 90 | # EMC() - end marked content | ||
| 91 | # MP(tag) - marked content point | ||
| 92 | # DP(tag,props) - marked content point with properties | ||
| 93 | # | ||
| 94 | # Utility: | ||
| 95 | # new() - create new canvas | ||
| 96 | # to_bytes() - get content stream bytes | ||
| 97 | # len() - get current length | ||
| 98 | # clear() - reset the canvas | ||
| 99 | # DESTROY() - cleanup | ||
| 100 | |||
| 101 | # Line cap styles | ||
| 102 | 61 | ▶ | use constant { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 103 | 61 | CAP_BUTT => 0, | |
| 104 | CAP_ROUND => 1, | ||
| 105 | CAP_SQUARE => 2, | ||
| 106 | 61 | }; | |
| 107 | |||
| 108 | # Line join styles | ||
| 109 | 61 | ▶ | use constant { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 110 | 61 | JOIN_MITER => 0, | |
| 111 | JOIN_ROUND => 1, | ||
| 112 | JOIN_BEVEL => 2, | ||
| 113 | 61 | }; | |
| 114 | |||
| 115 | # Text rendering modes | ||
| 116 | 61 | ▶ | use constant { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 117 | 61 | RENDER_FILL => 0, | |
| 118 | RENDER_STROKE => 1, | ||
| 119 | RENDER_FILL_STROKE => 2, | ||
| 120 | RENDER_INVISIBLE => 3, | ||
| 121 | RENDER_FILL_CLIP => 4, | ||
| 122 | RENDER_STROKE_CLIP => 5, | ||
| 123 | RENDER_FILL_STROKE_CLIP => 6, | ||
| 124 | RENDER_CLIP => 7, | ||
| 125 | 61 | }; | |
| 126 | |||
| 127 | 61 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 128 | 61 | our @EXPORT_OK = qw( | |
| 129 | CAP_BUTT CAP_ROUND CAP_SQUARE | ||
| 130 | JOIN_MITER JOIN_ROUND JOIN_BEVEL | ||
| 131 | RENDER_FILL RENDER_STROKE RENDER_FILL_STROKE RENDER_INVISIBLE | ||
| 132 | RENDER_FILL_CLIP RENDER_STROKE_CLIP RENDER_FILL_STROKE_CLIP RENDER_CLIP | ||
| 133 | ); | ||
| 134 | 61 | our %EXPORT_TAGS = ( | |
| 135 | caps => [qw(CAP_BUTT CAP_ROUND CAP_SQUARE)], | ||
| 136 | joins => [qw(JOIN_MITER JOIN_ROUND JOIN_BEVEL)], | ||
| 137 | render => [qw( | ||
| 138 | RENDER_FILL RENDER_STROKE RENDER_FILL_STROKE RENDER_INVISIBLE | ||
| 139 | RENDER_FILL_CLIP RENDER_STROKE_CLIP RENDER_FILL_STROKE_CLIP RENDER_CLIP | ||
| 140 | )], | ||
| 141 | all => \@EXPORT_OK, | ||
| 142 | ); | ||
| 143 | |||
| 144 | 61 | 1; | |
| 145 | |||
| 146 | __END__ | ||