aboutsummaryrefslogtreecommitdiff
path: root/src/client/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views')
-rw-r--r--src/client/views/GestureOverlay.tsx7
-rw-r--r--src/client/views/InkControls.tsx24
-rw-r--r--src/client/views/InkStrokeProperties.ts12
-rw-r--r--src/client/views/InkingStroke.tsx3
4 files changed, 9 insertions, 37 deletions
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index cf57ac7a1..bbf21f22c 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -733,7 +733,7 @@ export class GestureOverlay extends Touchable {
const centerX = (Math.max(left, right) + Math.min(left, right)) / 2;
const centerY = (Math.max(top, bottom) + Math.min(top, bottom)) / 2;
const radius = Math.max(centerX - Math.min(left, right), centerY - Math.min(top, bottom));
- // Dividing the circle into four equal sections, and fiting each section to a cubic Bézier curve.
+ // Dividing the circle into four equal sections, and fitting each section to a cubic Bézier curve.
this._points.push({ X: centerX - radius, Y: centerY });
this._points.push({ X: centerX - radius, Y: centerY + (c * radius) });
this._points.push({ X: centerX - (c * radius), Y: centerY + radius });
@@ -754,11 +754,6 @@ export class GestureOverlay extends Touchable {
this._points.push({ X: centerX - radius, Y: centerY - (c * radius) });
this._points.push({ X: centerX - radius, Y: centerY });
- // this._points.push({ X: centerX - radius, Y: centerY });
- // this._points.push({ X: centerX - radius, Y: centerY - (c * radius) });
- // this._points.push({ X: centerX - (c * radius), Y: centerY - radius });
- // this._points.push({ X: centerX, Y: centerY - radius });
-
break;
case "line":
diff --git a/src/client/views/InkControls.tsx b/src/client/views/InkControls.tsx
index 55a70ccd2..6213a4075 100644
--- a/src/client/views/InkControls.tsx
+++ b/src/client/views/InkControls.tsx
@@ -87,38 +87,16 @@ export class InkControls extends React.Component<InkControlProps> {
if (!formatInstance) return (null);
// Accessing the current ink's data and extracting all control points.
- // Separate case for circle shape (?)
const data = this.props.data;
- const [left, right, top, bottom, scaleX, scaleY, strokeWidth] = this.props.format;
- const centerX = (Math.max(left, right) + Math.min(left, right)) / 2;
- const centerY = (Math.max(top, bottom) + Math.min(top, bottom)) / 2;
- const radius = Math.max(centerX - Math.min(left, right), centerY - Math.min(top, bottom));
const controlPoints: ControlPoint[] = [];
if (data.length >= 4) {
- // const distance = Math.sqrt((Math.pow(data[0].X - centerX, 2)) + (Math.pow(data[0].Y - centerY, 2)));
- // if (Math.abs(distance - radius) <= 2.5) {
- // controlPoints.push({ X: data[0].X, Y: data[0].Y, I: 0 });
- // const topPoint = formatInstance.rotatePoint(data[0], { X: centerX, Y: centerY }, Math.PI / 2);
- // const rightPoint = formatInstance.rotatePoint(data[0], { X: centerX, Y: centerY }, Math.PI);
- // const bottomPoint = formatInstance.rotatePoint(data[0], { X: centerX, Y: centerY }, Math.PI * 1.5);
- // for (let i = 0; i <= data.length - 4; i += 4) {
- // const currPoint = data[i];
- // const isTopPoint = Math.sqrt((Math.pow(currPoint.X - topPoint.X, 2)) + (Math.pow(currPoint.Y - topPoint.Y, 2))) <= 2.5;
- // const isRightPoint = Math.sqrt((Math.pow(currPoint.X - rightPoint.X, 2)) + (Math.pow(currPoint.Y - rightPoint.Y, 2))) <= 2.5;
- // const isBottomPoint = Math.sqrt((Math.pow(currPoint.X - bottomPoint.X, 2)) + (Math.pow(currPoint.Y - bottomPoint.Y, 2))) <= 2.5;
- // if (isTopPoint || isRightPoint || isBottomPoint) {
- // controlPoints.push({ X: data[i].X, Y: data[i].Y, I: i });
- // }
- // }
- // controlPoints.push({ X: data[0].X, Y: data[0].Y, I: 0 });
- // } else {
for (let i = 0; i <= data.length - 4; i += 4) {
controlPoints.push({ X: data[i].X, Y: data[i].Y, I: i });
controlPoints.push({ X: data[i + 3].X, Y: data[i + 3].Y, I: i + 3 });
}
- // }
}
const addedPoints = this.props.addedPoints;
+ const [left, top, scaleX, scaleY, strokeWidth] = this.props.format;
return (
<>
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index 7ef6606c4..d527b2a05 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -266,12 +266,12 @@ export class InkStrokeProperties {
this.applyFunction((doc: Doc, ink: InkData) => {
const brokenIndices = Cast(doc.brokenInkIndices, listSpec("number"));
if (brokenIndices) {
- let newBrokenIndices = new List;
- for (let i = 0; i < brokenIndices.length; i++) {
- if (brokenIndices[i] !== controlIndex) {
- newBrokenIndices.push(brokenIndices[i]);
+ const newBrokenIndices = new List;
+ brokenIndices.forEach(brokenIndex => {
+ if (brokenIndex !== controlIndex) {
+ newBrokenIndices.push(brokenIndex);
}
- }
+ });
doc.brokenInkIndices = newBrokenIndices;
const [controlPoint, handleA, handleB] = [ink[controlIndex], ink[handleIndexA], ink[handleIndexB]];
const oppositeHandleA = this.rotatePoint(handleA, controlPoint, Math.PI);
@@ -288,7 +288,7 @@ export class InkStrokeProperties {
*/
@action
rotatePoint = (target: PointData, origin: PointData, angle: number) => {
- let rotatedTarget = { X: target.X - origin.X, Y: target.Y - origin.Y };
+ const rotatedTarget = { X: target.X - origin.X, Y: target.Y - origin.Y };
const newX = Math.cos(angle) * rotatedTarget.X - Math.sin(angle) * rotatedTarget.Y;
const newY = Math.sin(angle) * rotatedTarget.X + Math.cos(angle) * rotatedTarget.Y;
rotatedTarget.X = newX + origin.X;
diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx
index affea61e3..834c3b745 100644
--- a/src/client/views/InkingStroke.tsx
+++ b/src/client/views/InkingStroke.tsx
@@ -29,7 +29,6 @@ const InkDocument = makeInterface(documentSchema);
export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocument>(InkDocument) {
static readonly MaskDim = 50000;
@observable private _properties?: InkStrokeProperties;
- // static InkShape = GestureOverlay.Instance.InkShape;
constructor(props: FieldViewProps & InkDocument) {
super(props);
@@ -142,7 +141,7 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume
inkDoc={inkDoc}
data={data}
addedPoints={addedPoints}
- format={[left, right, top, bottom, scaleX, scaleY, strokeWidth]}
+ format={[left, top, scaleX, scaleY, strokeWidth]}
ScreenToLocalTransform={this.props.ScreenToLocalTransform} />
<InkHandles
inkDoc={inkDoc}