add more rando
This commit is contained in:
		@ -5,17 +5,28 @@ export interface JustifiedImage extends JustifiedInputImage {
 | 
			
		||||
  height: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function shuffleImages<T>(arr: T[]): T[] {
 | 
			
		||||
  const shuffled = [...arr];
 | 
			
		||||
  for (let i = shuffled.length - 1; i > 0; i--) {
 | 
			
		||||
    const j = Math.floor(Math.random() * (i + 1));
 | 
			
		||||
    [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
 | 
			
		||||
  }
 | 
			
		||||
  return shuffled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function justifyPortfolioImages(
 | 
			
		||||
  images: JustifiedInputImage[],
 | 
			
		||||
  containerWidth: number,
 | 
			
		||||
  rowHeight: number,
 | 
			
		||||
  gap: number = 4
 | 
			
		||||
): JustifiedImage[][] {
 | 
			
		||||
  const shuffledImages = shuffleImages(images);
 | 
			
		||||
 | 
			
		||||
  const rows: JustifiedImage[][] = [];
 | 
			
		||||
  let currentRow: JustifiedInputImage[] = [];
 | 
			
		||||
  let currentWidth = 0;
 | 
			
		||||
 | 
			
		||||
  for (const image of images) {
 | 
			
		||||
  for (const image of shuffledImages) {
 | 
			
		||||
    const scale = rowHeight / image.height;
 | 
			
		||||
    const scaledWidth = image.width * scale;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user