Improves drawing

canvas-rendering
Steve Ruiz 2021-06-12 17:34:38 +01:00
rodzic b8d58f2d50
commit 58c9fc9f83
2 zmienionych plików z 13 dodań i 9 usunięć

Wyświetl plik

@ -80,17 +80,25 @@ export default class BrushSession extends BaseSession {
}
}
// Round the new point (helps keep our data tidy)
// Low pass the current input point against the previous one
const nextPrev = vec.med(this.previous, point)
// A delta to project the projected point
const offset = vec.mul(vec.sub(nextPrev, this.previous), 2)
this.previous = nextPrev
// Generate some temporary points towards a projected point
const temporaryPoints = [0.7, 0.9, 0.95, 1].map((v) =>
vec.round([
...vec.sub(vec.lrp(this.previous, point, v), this.origin),
...vec.sub(
vec.lrp(this.previous, vec.add(point, offset), v),
this.origin
),
pressure,
])
)
// Low pass the current input point against the previous one
this.previous = vec.med(this.previous, point)
// Don't add duplicate points. It's important to test against the
// adjusted (low-passed) point rather than the input point.

Wyświetl plik

@ -19,9 +19,6 @@ import {
getShape,
screenToWorld,
setZoomCSS,
translateBounds,
getParentOffset,
getParentRotation,
rotateBounds,
getBoundsCenter,
getDocumentBranch,
@ -45,7 +42,6 @@ import {
DashStyle,
SizeStyle,
ColorStyle,
Bounds,
} from 'types'
import session from './session'
import { pointInBounds } from 'utils/bounds'