diff --git a/src/add-sample.ts b/src/add-sample.ts index 3bc2044..23ef41e 100644 --- a/src/add-sample.ts +++ b/src/add-sample.ts @@ -53,7 +53,7 @@ export function addSample( context2d.drawImage(img, 0, 0, canvas.width, canvas.height) return addSample( context, - context2d.getImageData(0, 0, img.width, img.height).data, + context2d.getImageData(0, 0, canvas.width, canvas.height).data, options, ) }) diff --git a/src/create-palette.ts b/src/create-palette.ts index c55a851..60481a4 100644 --- a/src/create-palette.ts +++ b/src/create-palette.ts @@ -58,7 +58,9 @@ export function createPalette(options?: Options | Context): Palette { return result }, - generate(options) { + generate(options = {}) { + const { clearSamples = true } = options + if (clearSamples) previousSample = null generate(context, options) return this },