- 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
/**
* Supported line joints in `PIXI.LineStyle` for graphics.
* @see PIXI.Graphics#lineStyle
* @see https://graphicdesign.stackexchange.com/questions/59018/what-is-a-bevel-join-of-two-lines-exactly-illustrator
* @name LINE_JOIN
* @memberof PIXI
* @static
* @enum {string}
* @property {string} MITER - 'miter': make a sharp corner where outer part of lines meet
* @property {string} BEVEL - 'bevel': add a square butt at each end of line segment and fill the triangle at turn
* @property {string} ROUND - 'round': add an arc at the joint
*/
export enum LINE_JOIN
// eslint-disable-next-line @typescript-eslint/indent
{
MITER = 'miter',
BEVEL = 'bevel',
ROUND = 'round'
}
/**
* Support line caps in `PIXI.LineStyle` for graphics.
* @see PIXI.Graphics#lineStyle
* @name LINE_CAP
* @memberof PIXI
* @static
* @enum {string}
* @property {string} BUTT - 'butt': don't add any cap at line ends (leaves orthogonal edges)
* @property {string} ROUND - 'round': add semicircle at ends
* @property {string} SQUARE - 'square': add square at end (like `BUTT` except more length at end)
*/
export enum LINE_CAP
// eslint-disable-next-line @typescript-eslint/indent
{
BUTT = 'butt',
ROUND = 'round',
SQUARE = 'square'
}
export interface IGraphicsCurvesSettings
{
adaptive: boolean;
maxLength: number;
minSegments: number;
maxSegments: number;
epsilon: number;
_segmentsCount(length: number, defaultSegments?: number): number;
}
/**
* Graphics curves resolution settings. If `adaptive` flag is set to `true`,
* the resolution is calculated based on the curve's length to ensure better visual quality.
* Adaptive draw works with `bezierCurveTo` and `quadraticCurveTo`.
* @static
* @constant
* @memberof PIXI
* @name GRAPHICS_CURVES
* @type {object}
* @property {boolean} [adaptive=true] - flag indicating if the resolution should be adaptive
* @property {number} [maxLength=10] - maximal length of a single segment of the curve (if adaptive = false, ignored)
* @property {number} [minSegments=8] - minimal number of segments in the curve (if adaptive = false, ignored)
* @property {number} [maxSegments=2048] - maximal number of segments in the curve (if adaptive = false, ignored)
*/
export const GRAPHICS_CURVES: IGraphicsCurvesSettings = {
adaptive: true,
maxLength: 10,
minSegments: 8,
maxSegments: 2048,
epsilon: 0.0001,
_segmentsCount(length: number, defaultSegments = 20)
{
if (!this.adaptive || !length || isNaN(length))
{
return defaultSegments;
}
let result = Math.ceil(length / this.maxLength);
if (result < this.minSegments)
{
result = this.minSegments;
}
else if (result > this.maxSegments)
{
result = this.maxSegments;
}
return result;
},
};