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
|
.. default-domain:: js
.. highlight:: javascript
StrokeState
===========
A StrokeState controls the properties of how stroking operations are performed.
Besides controlling the line width, it is also possible to control
:term:`line cap style`, :term:`line join style`, and the :term:`miter limit`.
Constructors
------------
.. class:: StrokeState(template)
Create a new empty stroke state object.
The Javascript object used as template allows for setting
the following attributes:
* "lineCap": string: The :term:`line cap style` to be used. One of ``"Butt" | "Round" | "Square"``
* "lineJoin": string: The :term:`line join style` to be used. One of ``"Miter" | "Round" | "Bevel"``
* "lineWidth": number: The line width to be used.
* "miterLimit": number: The :term:`miter limit` to be used.
* "dashPhase": number: The dash phase to be used.
* "dashPattern": Array of number: The sequence of dash lengths to be used.
:param Object template: An object with the parameters to set.
.. code-block::
var strokeState = new mupdf.StrokeState({
lineCap: "Square",
lineJoin: "Bevel",
lineWidth: 2.0,
miterLimit: 1.414,
dashPhase: 11,
dashPattern: [ 2, 3 ]
})
Instance methods
----------------
.. method:: StrokeState.prototype.getLineCap()
Get the :term:`line cap style`.
:returns: ``"Butt" | "Round" | "Square"``
.. code-block::
var lineCap = strokeState.getLineCap()
.. method:: StrokeState.prototype.getLineJoin()
Get the :term:`line join style`.
:returns: ``"Miter" | "Round" | "Bevel"``
.. code-block::
var lineJoin = strokeState.getLineJoin()
.. method:: StrokeState.prototype.getLineWidth()
Get the line line width.
:returns: number
.. code-block::
var width = strokeState.getLineWidth()
.. method:: StrokeState.prototype.getMiterLimit()
Get the :term:`miter limit`.
:returns: number
.. code-block::
var limit = strokeState.getMiterLimit()
.. method:: StrokeState.prototype.getDashPhase()
Get the dash pattern phase (where in the dash pattern stroking starts).
:returns: number
.. code-block:: javascript
var limit = strokeState.getDashPhase()
.. method:: StrokeState.prototype.getDashPattern()
Get the dash pattern as an array of numbers specifying alternating
lengths of dashes and gaps, or null if none set.
:returns: Array of number | null
.. code-block:: javascript
var dashPattern = strokeState.getDashPattern()
|