Skip to content

Commit

Permalink
fix: BlendMode::Source should be copy instead of source
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 16, 2022
1 parent 9e32756 commit a010fba
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions __test__/draw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}>
Expand Down
8 changes: 5 additions & 3 deletions __test__/echarts.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions __test__/filter.spec.ts
Original file line number Diff line number Diff line change
@@ -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
}>
Expand Down
4 changes: 2 additions & 2 deletions __test__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -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
}>
Expand Down
4 changes: 2 additions & 2 deletions __test__/svg-canvas.spec.ts
Original file line number Diff line number Diff line change
@@ -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
}>

Expand Down
4 changes: 2 additions & 2 deletions __test__/text.spec.ts
Original file line number Diff line number Diff line change
@@ -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
}>
Expand Down
4 changes: 2 additions & 2 deletions src/sk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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),
Expand Down

1 comment on commit a010fba

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: a010fba Previous: 9e32756 Ratio
Draw house#skia-canvas 21.66 ops/sec (±0.22%) 18 ops/sec (±0.17%) 0.83
Draw house#node-canvas 23.24 ops/sec (±0.28%) 19 ops/sec (±0.21%) 0.82
Draw house#@napi-rs/skia 23.16 ops/sec (±0.13%) 21 ops/sec (±0.82%) 0.91
Draw gradient#skia-canvas 20.7 ops/sec (±1.04%) 17 ops/sec (±0.36%) 0.82
Draw gradient#node-canvas 22.1 ops/sec (±0.21%) 18 ops/sec (±0.19%) 0.81
Draw gradient#@napi-rs/skia 22.2 ops/sec (±0.18%) 20 ops/sec (±0.1%) 0.90

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.