Skip to content

Commit

Permalink
fix: screen effect
Browse files Browse the repository at this point in the history
  • Loading branch information
LuciNyan committed Mar 28, 2024
1 parent 8b49be4 commit afccff3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/pixel-profile/src/renderer/texture-filter/linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export function genBiLinearFilter(pixels: Buffer, width: number, height: number)
return tmp1 * (1 - sy) + tmp2 * sy
}
function biLinearFilter(coords: Coordinates): RGBA {
coords[0] = clamp(coords[0], 0, 1)
coords[1] = clamp(coords[1], 0, 1)

const x = coords[0] * maxX
const y = coords[1] * maxY
const x0 = clamp(Math.floor(x), 0, maxX)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { clamp } from '../../utils'
import { Coordinates, coordsToPixel, RGBA, Texture2D } from '../common'

export function genNearestNeighborFilter(pixels: Buffer, width: number, height: number): Texture2D {
const maxX = width - 1
const maxY = height - 1

function nearestNeighborFilter(coords: Coordinates): RGBA {
coords[0] = clamp(coords[0], 0, 1)
coords[1] = clamp(coords[1], 0, 1)

const x = coords[0] * maxX
const y = coords[1] * maxY

// 计算最近邻像素的坐标
const nearestX = Math.round(x)
const nearestY = Math.round(y)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit afccff3

Please sign in to comment.