Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 183 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 11x 11x 11x 11x 1x 1x 1x 1x 1x 8x 8x 1x 9x 9x 9x 9x 1x 7x 7x 1x 1x 1x 1x 1x 1x | /* * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey * http://juerglehni.com/ & https://puckey.studio/ * * Distributed under the MIT license. See LICENSE file for details. * * All rights reserved. */ // TODO: remove eslint-disable comment and deal with errors over time /* eslint-disable */ import { Base } from '~/straps'; import { Point } from '~/basic/Point'; import { Change } from '~/item/ChangeFlag'; import { Item } from '~/item/Item'; /** * @name TextItem * * @class The TextItem type allows you to create typography. Its functionality * is inherited by different text item types such as {@link PointText}, and * {@link AreaText} (coming soon). They each add a layer of functionality * that is unique to their type, but share the underlying properties and * functions that they inherit from TextItem. * * @extends Item */ export const TextItem = Item.extend( /** @lends TextItem# */ { _class: 'TextItem', _applyMatrix: false, _canApplyMatrix: false, _serializeFields: { content: null, }, // TextItem doesn't make the distinction between the different bounds, // so use the same name for all of them _boundsOptions: { stroke: false, handle: false }, initialize: function TextItem(arg) { this._content = ''; this._lines = []; // Support two forms of item initialization: Passing one object literal // describing all the different properties to be set, or a point where // it should be placed (arg). // See if a point is passed, and if so, pass it on to _initialize(). // If not, it might be a properties object literal. var hasProps = arg && Base.isPlainObject(arg) && arg.x === undefined && arg.y === undefined; this._initialize(hasProps && arg, !hasProps && Point.read(arguments)); }, _equals: function (item) { return this._content === item._content; }, copyContent: function (source) { this.setContent(source._content); }, /** * The text contents of the text item. * * @bean * @type String * * @example {@paperscript} * // Setting the content of a PointText item: * * // Create a point-text item at {x: 30, y: 30}: * var text = new PointText(new Point(30, 30)); * text.fillColor = 'black'; * * // Set the content of the text item: * text.content = 'Hello world'; * * @example {@paperscript} * // Interactive example, move your mouse over the view below: * * // Create a point-text item at {x: 30, y: 30}: * var text = new PointText(new Point(30, 30)); * text.fillColor = 'black'; * * text.content = 'Move your mouse over the view, to see its position'; * * function onMouseMove(event) { * // Each time the mouse is moved, set the content of * // the point text to describe the position of the mouse: * text.content = 'Your position is: ' + event.point.toString(); * } */ getContent: function () { return this._content; }, setContent: function (content) { this._content = '' + content; this._lines = this._content.split(/\r\n|\n|\r/gm); this._changed(/*#=*/ Change.CONTENT); }, isEmpty: function () { return !this._content; }, /** * {@grouptitle Character Style} * * The font-family to be used in text content. * * @name TextItem#fontFamily * @type String * @default 'sans-serif' */ /** * * The font-weight to be used in text content. * * @name TextItem#fontWeight * @type String|Number * @default 'normal' */ /** * The font size of text content, as a number in pixels, or as a string with * optional units `'px'`, `'pt'` and `'em'`. * * @name TextItem#fontSize * @type Number|String * @default 10 */ /** * * The font-family to be used in text content, as one string. * @deprecated use {@link #fontFamily} instead. * * @name TextItem#font * @type String * @default 'sans-serif' */ /** * The text leading of text content. * * @name TextItem#leading * @type Number|String * @default fontSize * 1.2 */ /** * {@grouptitle Paragraph Style} * * The justification of text paragraphs. * * @name TextItem#justification * @type String * @values 'left', 'right', 'center' * @default 'left' */ /** * @bean * @private * @deprecated use {@link #style} instead. */ getCharacterStyle: '#getStyle', setCharacterStyle: '#setStyle', /** * @bean * @private * @deprecated use {@link #style} instead. */ getParagraphStyle: '#getStyle', setParagraphStyle: '#setStyle', } ); |