Skip to content

Commit

Permalink
feat: enhance shader
Browse files Browse the repository at this point in the history
  • Loading branch information
LuciNyan committed Feb 23, 2024
1 parent 57b1743 commit 0806fbf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

4 changes: 2 additions & 2 deletions packages/pixel-profile/src/shaders/curve.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Coordinates, Vec2 } from '../utils'
import { dot2, prod2, render, subtract2 } from '../utils'
import { add2, dot2, prod2, render, subtract2 } from '../utils'

const margin = [0, 0]
const screenCurvature = 0.1
Expand All @@ -13,7 +13,7 @@ export function curve(source: Buffer, width: number, height: number): Buffer {
cc[0] = cc[0] * temp
cc[1] = cc[1] * temp

return [coords[0] + cc[0], coords[1] + cc[1]]
return add2(coords, cc)
}

const coords = distortCoordinates(uv)
Expand Down
2 changes: 1 addition & 1 deletion packages/pixel-profile/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { getBase64FromPixels, getPixelsFromPngBuffer, getPngBufferFromPixels } from './converter'
export { clamp, dot2, kFormatter, prod2, subtract2, type Vec2 } from './math'
export { add2, clamp, dot2, kFormatter, prod2, subtract2, type Vec2 } from './math'
export { type Rank, rank } from './rank'
export { type Coordinates, render } from './renderer'
export { request } from './request'
Expand Down
4 changes: 4 additions & 0 deletions packages/pixel-profile/src/utils/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export function kFormatter(num: number): string {
: `${Math.sign(num) * Math.abs(num)}`
}

export function add2(a: Vec2, b: Vec2): Vec2 {
return [a[0] + b[0], a[1] + b[1]]
}

export function dot2(a: Vec2, b: Vec2): number {
return a[0] * b[0] + a[1] * b[1]
}
Expand Down

0 comments on commit 0806fbf

Please sign in to comment.