* Get minumum length that can make a repeatable pattern.
*
* @return {Object} pattern width and height
*/
functiongetPatternSize()
:{
width:number,
height:number,
lines:number
}
{
functiongetPatternSize():{
width:number,
height:number,
lines:number
}{
/**
* For example, if dash is [[3, 2], [2, 1]] for X, it looks like
* |--- --- --- --- --- ...
...
...
@@ -160,10 +172,11 @@ export function createOrUpdatePatternFromDecal(
constcolumns=decalOpt.dashLineOffset
?width/offsetMultipleX
:2;
letheight=lineBlockLengthY*columns;
constheight=lineBlockLengthY*columns;
if(__DEV__){
constwarn=(attrName:string)=>{
/* eslint-disable-next-line */
console.warn(`Calculated decal size is greater than ${attrName} due to decal option settings so ${attrName} is used for the decal size. Please consider changing the decal option to make a smaller decal or set ${attrName} to be larger to avoid incontinuity.`);
};
if(width>decalOpt.maxTileWidth){
...
...
@@ -182,15 +195,14 @@ export function createOrUpdatePatternFromDecal(
}
functionbrushDecal(){
constctx=canvas.getContext('2d');
ctx.clearRect(0,0,canvas.width,canvas.height);
if(decalOpt.backgroundColor){
ctx.fillStyle=decalOpt.backgroundColor;
ctx.fillRect(0,0,canvas.width,canvas.height);
if(ctx){
ctx.clearRect(0,0,canvas.width,canvas.height);
if(decalOpt.backgroundColor){
ctx.fillStyle=decalOpt.backgroundColor;
ctx.fillRect(0,0,canvas.width,canvas.height);
}
}
ctx.fillStyle=decalOpt.color;
letySum=0;
for(leti=0;i<dashArrayY.length;++i){
ySum+=dashArrayY[i];
...
...
@@ -254,15 +266,21 @@ export function createOrUpdatePatternFromDecal(