refactor(background): use repeating inline svg as bg pattern #356
This commit is contained in:
@@ -1,37 +1,13 @@
|
||||
export const createGridLinesPath = (
|
||||
width: number,
|
||||
height: number,
|
||||
xOffset: number,
|
||||
yOffset: number,
|
||||
gap: number
|
||||
): string => {
|
||||
const lineCountX = Math.ceil(width / gap) + 1;
|
||||
const lineCountY = Math.ceil(height / gap) + 1;
|
||||
export const createGridLinesPath = (xOffset: number, yOffset: number, scaledGap: number): string => {
|
||||
const x = xOffset < 0 ? scaledGap + xOffset : xOffset;
|
||||
const y = yOffset < 0 ? scaledGap + yOffset : yOffset;
|
||||
|
||||
const xValues = Array.from({ length: lineCountX }, (_, i) => `M${i * gap + xOffset} 0 V${height}`);
|
||||
const yValues = Array.from({ length: lineCountY }, (_, i) => `M0 ${i * gap + yOffset} H${width}`);
|
||||
|
||||
return [...xValues, ...yValues].join(' ');
|
||||
return `M${x} 0 V${scaledGap} M0 ${y} H${scaledGap}`;
|
||||
};
|
||||
|
||||
export const createGridDotsPath = (
|
||||
width: number,
|
||||
height: number,
|
||||
xOffset: number,
|
||||
yOffset: number,
|
||||
gap: number,
|
||||
size: number
|
||||
): string => {
|
||||
const lineCountX = Math.ceil(width / gap) + 1;
|
||||
const lineCountY = Math.ceil(height / gap) + 1;
|
||||
export const createGridDotsPath = (xOffset: number, yOffset: number, scaledGap: number, size: number): string => {
|
||||
const x = xOffset < 0 ? scaledGap + xOffset : xOffset;
|
||||
const y = yOffset < 0 ? scaledGap + yOffset : yOffset;
|
||||
|
||||
const values = Array.from({ length: lineCountX }, (_, col) => {
|
||||
const x = col * gap + xOffset;
|
||||
return Array.from({ length: lineCountY }, (_, row) => {
|
||||
const y = row * gap + yOffset;
|
||||
return `M${x} ${y - size} l${size} ${size} l${-size} ${size} l${-size} ${-size}z`;
|
||||
}).join(' ');
|
||||
});
|
||||
|
||||
return values.join(' ');
|
||||
return `M${x} ${y - size} l${size} ${size} l${-size} ${size} l${-size} ${-size}z`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user