Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Adds maxWeight to Signature component #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/signature/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class App extends Component {
<ExpoPixi.Signature
ref={ref => (this.sketch = ref)}
style={styles.sketch}
maxWeight={1}
strokeColor={'blue'}
strokeAlpha={1}
onReady={this.onReady}
Expand Down
4 changes: 2 additions & 2 deletions lib/components/Signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ global.__ExpoSignatureId = global.__ExpoSignatureId || 0;
type Props = {
strokeColor: number | string,
strokeAlpha: number,
maxWeight: number,
onChange: () => PIXI.Renderer,
onReady: () => WebGLRenderingContext,
};
Expand All @@ -36,8 +37,7 @@ export default class Signature extends React.Component<Props> {

constructor(props, context) {
super(props, context);

this.provider = new BezierProvider();
this.provider = new BezierProvider(this.props.maxWeight);
this._setupPanResponder();
}

Expand Down
5 changes: 5 additions & 0 deletions lib/core/signature/SignatureBezierProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { EventEmitter } from 'fbemitter';
import { vec2 } from 'gl-matrix';

class SignatureBezierProvider extends EventEmitter {
constructor(maxWeight) {
super()
SignatureBezierProvider.maxWeight = maxWeight || SignatureBezierProvider.maxWeight
}

static dotWeight = 3;
static pointsPerLine = 4;
static touchDistanceThreshold = 2;
Expand Down