From a010fba4c8e7ae3bed2e8119c6862c98e5a466b4 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 16 Feb 2022 13:00:39 +0800 Subject: [PATCH] fix: BlendMode::Source should be copy instead of source --- __test__/draw.spec.ts | 4 ++-- __test__/echarts.spec.ts | 8 +++++--- __test__/filter.spec.ts | 4 ++-- __test__/index.spec.ts | 4 ++-- __test__/svg-canvas.spec.ts | 4 ++-- __test__/text.spec.ts | 4 ++-- src/sk.rs | 4 ++-- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/__test__/draw.spec.ts b/__test__/draw.spec.ts index 8b874b02..d807289c 100644 --- a/__test__/draw.spec.ts +++ b/__test__/draw.spec.ts @@ -2,13 +2,13 @@ import { promises, readFileSync } from 'fs' import { platform } from 'os' import { join } from 'path' -import ava, { TestInterface } from 'ava' +import ava, { TestFn } from 'ava' import PNG from '@jimp/png' import { GlobalFonts, createCanvas, Canvas, Image, ImageData, Path2D, SKRSContext2D, DOMMatrix } from '../index' import { snapshotImage } from './image-snapshot' -const test = ava as TestInterface<{ +const test = ava as TestFn<{ canvas: Canvas ctx: SKRSContext2D }> diff --git a/__test__/echarts.spec.ts b/__test__/echarts.spec.ts index 934bc6f0..4b40e5f6 100644 --- a/__test__/echarts.spec.ts +++ b/__test__/echarts.spec.ts @@ -1,5 +1,5 @@ import test from 'ava' -import { init, setCanvasCreator } from 'echarts' +import { init, setPlatformAPI } from 'echarts' import { createCanvas } from '../index.js' import { snapshotImage } from './image-snapshot' @@ -10,8 +10,10 @@ test('echarts-start', async (t) => { return } const canvas = createCanvas(800, 600) - // @ts-expect-error - setCanvasCreator(() => canvas) + setPlatformAPI({ + // @ts-expect-error + createCanvas: () => canvas, + }) // @ts-expect-error const chart = init(canvas) chart.setOption({ diff --git a/__test__/filter.spec.ts b/__test__/filter.spec.ts index 3ecafc55..c355ac9a 100644 --- a/__test__/filter.spec.ts +++ b/__test__/filter.spec.ts @@ -1,13 +1,13 @@ import { promises as fs, readFileSync } from 'fs' import { join } from 'path' -import ava, { TestInterface } from 'ava' +import ava, { TestFn } from 'ava' import { createCanvas, Canvas, SKRSContext2D, Image } from '../index' import { snapshotImage } from './image-snapshot' -const test = ava as TestInterface<{ +const test = ava as TestFn<{ ctx: SKRSContext2D canvas: Canvas }> diff --git a/__test__/index.spec.ts b/__test__/index.spec.ts index 29624bed..a0198b9f 100644 --- a/__test__/index.spec.ts +++ b/__test__/index.spec.ts @@ -1,10 +1,10 @@ -import ava, { TestInterface } from 'ava' +import ava, { TestFn } from 'ava' import { createCanvas, Path2D, Canvas, SKRSContext2D } from '../index' import { snapshotImage } from './image-snapshot' -const test = ava as TestInterface<{ +const test = ava as TestFn<{ canvas: Canvas ctx: SKRSContext2D }> diff --git a/__test__/svg-canvas.spec.ts b/__test__/svg-canvas.spec.ts index 8e062f29..120c1269 100644 --- a/__test__/svg-canvas.spec.ts +++ b/__test__/svg-canvas.spec.ts @@ -1,10 +1,10 @@ import { join } from 'path' -import ava, { TestInterface } from 'ava' +import ava, { TestFn } from 'ava' import { createCanvas, SvgCanvas, SvgExportFlag, GlobalFonts } from '../index' -const test = ava as TestInterface<{ +const test = ava as TestFn<{ canvas: SvgCanvas }> diff --git a/__test__/text.spec.ts b/__test__/text.spec.ts index f1b8dee4..ba3a25f0 100644 --- a/__test__/text.spec.ts +++ b/__test__/text.spec.ts @@ -1,12 +1,12 @@ import { readFileSync } from 'fs' import { join } from 'path' -import ava, { TestInterface } from 'ava' +import ava, { TestFn } from 'ava' import { GlobalFonts, createCanvas, Canvas, SKRSContext2D } from '../index' import { snapshotImage } from './image-snapshot' -const test = ava as TestInterface<{ +const test = ava as TestFn<{ canvas: Canvas ctx: SKRSContext2D }> diff --git a/src/sk.rs b/src/sk.rs index 278befdf..210caa4c 100644 --- a/src/sk.rs +++ b/src/sk.rs @@ -1127,7 +1127,7 @@ impl BlendMode { BlendMode::Saturation => "saturation", BlendMode::Screen => "screen", BlendMode::SoftLight => "soft-light", - BlendMode::Source => "source", + BlendMode::Source => "copy", BlendMode::SourceATop => "source-atop", BlendMode::SourceIn => "source-in", BlendMode::SourceOut => "source-out", @@ -1165,7 +1165,7 @@ impl FromStr for BlendMode { "saturation" => Ok(BlendMode::Saturation), "screen" => Ok(BlendMode::Screen), "soft-light" => Ok(BlendMode::SoftLight), - "source" => Ok(BlendMode::Source), + "copy" => Ok(BlendMode::Source), "source-atop" => Ok(BlendMode::SourceATop), "source-in" => Ok(BlendMode::SourceIn), "source-out" => Ok(BlendMode::SourceOut),