* Get minumum length that can make a repeatable pattern.
* Get minumum length that can make a repeatable pattern.
*
*
* @return {Object} pattern width and height
* @return {Object} pattern width and height
*/
*/
functiongetPatternSize()
functiongetPatternSize():{
:{
width:number,
width:number,
height:number,
height:number,
lines:number
lines:number
}{
}
{
/**
/**
* For example, if dash is [[3, 2], [2, 1]] for X, it looks like
* For example, if dash is [[3, 2], [2, 1]] for X, it looks like
* |--- --- --- --- --- ...
* |--- --- --- --- --- ...
...
@@ -160,10 +172,11 @@ export function createOrUpdatePatternFromDecal(
...
@@ -160,10 +172,11 @@ export function createOrUpdatePatternFromDecal(
constcolumns=decalOpt.dashLineOffset
constcolumns=decalOpt.dashLineOffset
?width/offsetMultipleX
?width/offsetMultipleX
:2;
:2;
letheight=lineBlockLengthY*columns;
constheight=lineBlockLengthY*columns;
if(__DEV__){
if(__DEV__){
constwarn=(attrName:string)=>{
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.`);
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){
if(width>decalOpt.maxTileWidth){
...
@@ -182,15 +195,14 @@ export function createOrUpdatePatternFromDecal(
...
@@ -182,15 +195,14 @@ export function createOrUpdatePatternFromDecal(
}
}
functionbrushDecal(){
functionbrushDecal(){
constctx=canvas.getContext('2d');
if(ctx){
ctx.clearRect(0,0,canvas.width,canvas.height);
ctx.clearRect(0,0,canvas.width,canvas.height);
if(decalOpt.backgroundColor){
if(decalOpt.backgroundColor){
ctx.fillStyle=decalOpt.backgroundColor;
ctx.fillStyle=decalOpt.backgroundColor;
ctx.fillRect(0,0,canvas.width,canvas.height);
ctx.fillRect(0,0,canvas.width,canvas.height);
}
}
}
ctx.fillStyle=decalOpt.color;
letySum=0;
letySum=0;
for(leti=0;i<dashArrayY.length;++i){
for(leti=0;i<dashArrayY.length;++i){
ySum+=dashArrayY[i];
ySum+=dashArrayY[i];
...
@@ -254,15 +266,21 @@ export function createOrUpdatePatternFromDecal(
...
@@ -254,15 +266,21 @@ export function createOrUpdatePatternFromDecal(