diff --git a/src/collages.ts b/src/collages.ts index 073fda7..3f7cae7 100644 --- a/src/collages.ts +++ b/src/collages.ts @@ -1,7 +1,7 @@ import {CollageConfig, CollageMode, Segment} from "@/types"; import {choice, randint, range, shuffle} from "@/utils"; -const collageModeType = [ +export const collageModeType = [ "clean_grid", "chaos_grid", "row", "irow", "col", "icol", @@ -91,7 +91,7 @@ const modes: { [key in CollageModeType]: CollageMode } = { name: "Regular Row", minImages: 2, getSegments: (ctx, config, images) => { - const numImages = Math.min(images?.length || 0, config?.numImages || randint(4) + 2); + const numImages = Math.min(images?.length || Infinity, config?.numImages || randint(4) + 2); const segmentSize = [ctx.canvas.width / numImages, ctx.canvas.height]; return range(numImages).map((idx) => { return { @@ -108,7 +108,7 @@ const modes: { [key in CollageModeType]: CollageMode } = { name: "Irregular Row", minImages: 2, getSegments: (ctx, config, images) => { - const numImages = Math.min(images?.length || 0, config?.numImages || randint(4) + 2); + const numImages = Math.min(images?.length || Infinity, config?.numImages || randint(4) + 2); const segmentSize = [ctx.canvas.width / numImages, ctx.canvas.height]; return range(numImages).map((idx) => { const irregularWidth = images ? @@ -128,7 +128,7 @@ const modes: { [key in CollageModeType]: CollageMode } = { name: "Regular Column", minImages: 2, getSegments: (ctx, config, images) => { - const numImages = Math.min(images?.length || 0, config?.numImages || randint(4) + 2); + const numImages = Math.min(images?.length || Infinity, config?.numImages || randint(4) + 2); const segmentSize = [ctx.canvas.width, ctx.canvas.height / numImages]; return range(numImages).map((idx) => { return { @@ -145,7 +145,7 @@ const modes: { [key in CollageModeType]: CollageMode } = { name: "Irregular Column", minImages: 2, getSegments: (ctx, config, images) => { - const numImages = Math.min(images?.length || 0, config?.numImages || randint(4) + 2); + const numImages = Math.min(images?.length || Infinity, config?.numImages || randint(4) + 2); const segmentSize = [ctx.canvas.width, ctx.canvas.height / numImages]; return range(numImages).map((idx) => { const irregularHeight = images ? @@ -165,7 +165,7 @@ const modes: { [key in CollageModeType]: CollageMode } = { name: "Constant factor concentric", minImages: 2, getSegments: (ctx, config, images) => { - const numImages = Math.min(images?.length || 0, config?.numImages || randint(4) + 2); + const numImages = Math.min(images?.length || Infinity, config?.numImages || randint(4) + 2); let factor: number; if (Math.random() > .5) { factor = choice([1 / Math.sqrt(2), .5, .88]); @@ -188,7 +188,7 @@ const modes: { [key in CollageModeType]: CollageMode } = { name: "Equally spaced concentric", minImages: 2, getSegments: (ctx, config, images) => { - const numImages = Math.min(images?.length || 0, config?.numImages || randint(2) + 2); + const numImages = Math.min(images?.length || Infinity, config?.numImages || randint(2) + 2); return range(numImages).map((idx) => { return { x: ctx.canvas.width / 2, @@ -204,7 +204,7 @@ const modes: { [key in CollageModeType]: CollageMode } = { name: "Blending", minImages: 2, getSegments: (ctx, config, images) => { - const numImages = Math.min(images?.length || 0, config?.numImages || randint(2) + 2); + const numImages = Math.min(images?.length || Infinity, config?.numImages || randint(2) + 2); return range(numImages).map((_) => { return { x: ctx.canvas.width / 2, diff --git a/src/components/Collage.vue b/src/components/Collage.vue index 6106681..08c3262 100644 --- a/src/components/Collage.vue +++ b/src/components/Collage.vue @@ -18,7 +18,7 @@ @@ -28,10 +28,16 @@ !SHUFFLE ALL! +