| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); define(["require", "exports", "./../pdf-graphics", "./pdf-brush", "./../../drawing/pdf-drawing", "./../../input-output/pdf-dictionary-properties", "./../../primitives/pdf-array", "./../../primitives/pdf-number", "./../pdf-graphics", "./../pdf-resources", "./../../primitives/pdf-stream", "./../../pages/pdf-page"], function (require, exports, pdf_graphics_1, pdf_brush_1, pdf_drawing_1, pdf_dictionary_properties_1, pdf_array_1, pdf_number_1, pdf_graphics_2, pdf_resources_1, pdf_stream_1, pdf_page_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var PdfTilingBrush = (function (_super) { __extends(PdfTilingBrush, _super); function PdfTilingBrush(arg1, arg2) { var _this = _super.call(this) || this; _this.mStroking = false; _this.mLocation = new pdf_drawing_1.PointF(0, 0); _this.mDictionaryProperties = new pdf_dictionary_properties_1.DictionaryProperties(); var rect = null; if (arg1 instanceof pdf_drawing_1.Rectangle) { rect = arg1; } else if (arg1 instanceof pdf_drawing_1.SizeF) { rect = new pdf_drawing_1.Rectangle(0, 0, arg1.width, arg1.height); } if (arg2 !== null && arg2 instanceof pdf_page_1.PdfPage) { _this.mPage = arg2; } _this.brushStream = new pdf_stream_1.PdfStream(); _this.mResources = new pdf_resources_1.PdfResources(); _this.brushStream.items.setValue(_this.mDictionaryProperties.resources, _this.mResources); _this.setBox(rect); _this.setObligatoryFields(); if (arg2 !== null && arg2 instanceof pdf_page_1.PdfPage) { _this.mPage = arg2; _this.graphics.colorSpace = arg2.document.colorSpace; } return _this; } PdfTilingBrush.prototype.initialize = function (rectangle, page, location, matrix) { this.mPage = page; this.mLocation = location; this.mTransformationMatrix = matrix; this.tempBrushStream = this.brushStream; this.brushStream = new pdf_stream_1.PdfStream(); var tempResource = new pdf_resources_1.PdfResources(); this.brushStream.items.setValue(this.mDictionaryProperties.resources, tempResource); this.setBox(rectangle); this.setObligatoryFields(); return this; }; Object.defineProperty(PdfTilingBrush.prototype, "location", { get: function () { return this.mLocation; }, set: function (value) { this.mLocation = value; }, enumerable: true, configurable: true }); PdfTilingBrush.prototype.setObligatoryFields = function () { this.brushStream.items.setValue(this.mDictionaryProperties.patternType, new pdf_number_1.PdfNumber(1)); this.brushStream.items.setValue(this.mDictionaryProperties.paintType, new pdf_number_1.PdfNumber(1)); this.brushStream.items.setValue(this.mDictionaryProperties.tilingType, new pdf_number_1.PdfNumber(1)); this.brushStream.items.setValue(this.mDictionaryProperties.xStep, new pdf_number_1.PdfNumber((this.mBox.right - this.mBox.left))); this.brushStream.items.setValue(this.mDictionaryProperties.yStep, new pdf_number_1.PdfNumber((this.mBox.bottom - this.mBox.top))); if ((this.mPage != null) && (this.mLocation != null)) { if ((this.mTransformationMatrix == null && typeof this.mTransformationMatrix === 'undefined')) { var tileTransform = (this.mPage.size.height % this.rectangle.size.height) - (this.mLocation.y); this.brushStream.items.setValue(this.mDictionaryProperties.matrix, new pdf_array_1.PdfArray([1, 0, 0, 1, this.mLocation.x, tileTransform])); } else { var tileTransform = 0; var elements = this.mTransformationMatrix.matrix.elements; if ((this.mPage.size.height > this.rectangle.size.height)) { tileTransform = (this.mTransformationMatrix.matrix.offsetY - (this.mPage.size.height % this.rectangle.size.height)); } else { tileTransform = ((this.mPage.size.height % this.rectangle.size.height) + this.mTransformationMatrix.matrix.offsetY); } this.brushStream.items.setValue(this.mDictionaryProperties.matrix, new pdf_array_1.PdfArray([ elements[0], elements[1], elements[2], elements[3], elements[4], tileTransform ])); } } }; PdfTilingBrush.prototype.setBox = function (box) { this.mBox = box; var rect = new pdf_drawing_1.RectangleF(this.mBox.left, this.mBox.top, this.mBox.right, this.mBox.bottom); this.brushStream.items.setValue(this.mDictionaryProperties.bBox, pdf_array_1.PdfArray.fromRectangle(rect)); }; Object.defineProperty(PdfTilingBrush.prototype, "rectangle", { get: function () { return this.mBox; }, enumerable: true, configurable: true }); Object.defineProperty(PdfTilingBrush.prototype, "size", { get: function () { return this.mBox.size; }, enumerable: true, configurable: true }); Object.defineProperty(PdfTilingBrush.prototype, "graphics", { get: function () { if ((this.mGraphics == null && typeof this.mGraphics === 'undefined')) { var gr = new pdf_graphics_1.GetResourceEventHandler(this); var g = new pdf_graphics_2.PdfGraphics(this.size, gr, this.brushStream); this.mGraphics = g; this.mResources = this.getResources(); this.mGraphics.initializeCoordinates(); } return this.mGraphics; }, enumerable: true, configurable: true }); PdfTilingBrush.prototype.getResources = function () { return this.mResources; }; Object.defineProperty(PdfTilingBrush.prototype, "stroking", { get: function () { return this.mStroking; }, set: function (value) { this.mStroking = value; }, enumerable: true, configurable: true }); PdfTilingBrush.prototype.clone = function () { var brush = this.initialize(this.rectangle, this.mPage, this.location, this.mTransformationMatrix); if ((this.mTransformationMatrix != null) && (this.mTransformationMatrix.matrix != null)) { brush.brushStream.items.setValue(this.mDictionaryProperties.matrix, new pdf_array_1.PdfArray(this.mTransformationMatrix.matrix.elements)); } brush.brushStream.data = this.tempBrushStream.data; brush.mResources = new pdf_resources_1.PdfResources(this.mResources); brush.brushStream.items.setValue(this.mDictionaryProperties.resources, brush.mResources); return brush; }; PdfTilingBrush.prototype.monitorChanges = function (brush, streamWriter, getResources, saveChanges, currentColorSpace) { var diff = false; if (brush !== this) { streamWriter.setColorSpace('Pattern', this.mStroking); var resources1 = getResources.getResources(); var name1 = resources1.getName(this); streamWriter.setColourWithPattern(null, name1, this.mStroking); diff = true; } else if (brush instanceof PdfTilingBrush) { streamWriter.setColorSpace('Pattern', this.mStroking); var resources = getResources.getResources(); var name_1 = resources.getName(this); streamWriter.setColourWithPattern(null, name_1, this.mStroking); diff = true; } return diff; }; PdfTilingBrush.prototype.resetChanges = function (streamWriter) { }; Object.defineProperty(PdfTilingBrush.prototype, "element", { get: function () { return this.brushStream; }, enumerable: true, configurable: true }); return PdfTilingBrush; }(pdf_brush_1.PdfBrush)); exports.PdfTilingBrush = PdfTilingBrush; }); |