Fix pressure (#3877)
This PR fixes pen pressure. Previously, `toFixed` loses the `z` of the point. ### Change Type - [x] `sdk` — Changes the tldraw SDK - [x] `bugfix` — Bug fix ### Test Plan 1. use a pen with pressure ### Release Notes - Fixes pen pressure.
This commit is contained in:
parent
15f1d82e7d
commit
876f1ef326
1 changed files with 4 additions and 3 deletions
|
@ -177,7 +177,8 @@ export class Drawing extends StateNode {
|
|||
// have our own value for this. The inputs.isPen is only if the input is a regular
|
||||
// pen, like an iPad pen, which needs to trigger "pen mode" in order to avoid
|
||||
// accidental palm touches. We don't have to worry about that with styluses though.
|
||||
const z = this.info.point.z === undefined ? 0.5 : this.info.point.z
|
||||
const { z = 0.5 } = this.info.point
|
||||
|
||||
this.isPen = isPen
|
||||
this.isPenOrStylus = isPen || (z > 0 && z < 0.5) || (z > 0.5 && z < 1)
|
||||
|
||||
|
@ -304,8 +305,8 @@ export class Drawing extends StateNode {
|
|||
const { segments } = shape.props
|
||||
|
||||
const { x, y, z } = this.editor.getPointInShapeSpace(shape, inputs.currentPagePoint).toFixed()
|
||||
|
||||
const newPoint = { x, y, z: this.isPenOrStylus ? +(z! * 1.25).toFixed(2) : 0.5 }
|
||||
const pressure = this.isPenOrStylus ? +(inputs.currentPagePoint.z! * 1.25).toFixed(2) : 0.5
|
||||
const newPoint = { x, y, z: pressure }
|
||||
|
||||
switch (this.segmentMode) {
|
||||
case 'starting_straight': {
|
||||
|
|
Loading…
Reference in a new issue