Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 2b3e80e

Browse files
authored
Merge pull request #154 from UnityTech/kgdev
fix clipPath.
2 parents 78b4370 + f956907 commit 2b3e80e

File tree

6 files changed

+44
-17
lines changed

6 files changed

+44
-17
lines changed

Runtime/material/animated_icons/animated_icons.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ public override void apply(Path path, float progress) {
188188
Offset controlPoint1 = AnimatedIconUtils._interpolate<Offset>(this.controlPoints1, progress, Offset.lerp);
189189
Offset controlPoint2 = AnimatedIconUtils._interpolate<Offset>(this.controlPoints2, progress, Offset.lerp);
190190
Offset targetPoint = AnimatedIconUtils._interpolate<Offset>(this.targetPoints, progress, Offset.lerp);
191-
// TODO: replace with cubicTo
192-
path.bezierTo(
191+
path.cubicTo(
193192
controlPoint1.dx, controlPoint1.dy,
194193
controlPoint2.dx, controlPoint2.dy,
195194
targetPoint.dx, targetPoint.dy

Runtime/painting/notched_shapes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ public override Path getOuterPath(Rect host, Rect guest) {
5656
Path ret = new Path();
5757
ret.moveTo(host.left, host.top);
5858
ret.lineTo(p[0].dx, p[0].dy);
59-
ret.quadTo(p[1].dx, p[1].dy, p[2].dx, p[2].dy);
59+
ret.quadraticBezierTo(p[1].dx, p[1].dy, p[2].dx, p[2].dy);
6060
// TODO: replace this lineTo() with arcToPoint when arcToPoint is ready
6161
ret.lineTo(p[3].dx, p[3].dy);
6262
// ret.arcToPoint(p[3], p[3], radius: Radius.circular(notchRadius), clockwise: false);
63-
ret.quadTo(p[4].dx, p[4].dy, p[5].dx, p[5].dy);
63+
ret.quadraticBezierTo(p[4].dx, p[4].dy, p[5].dx, p[5].dy);
6464
ret.lineTo(host.right, host.top);
6565
ret.lineTo(host.right, host.bottom);
6666
ret.lineTo(host.left, host.bottom);

Runtime/rendering/proxy_box.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,6 @@ public override void paint(PaintingContext context, Offset offset) {
10171017
this._updateClip();
10181018
context.pushClipPath(this.needsCompositing, offset, Offset.zero & this.size,
10191019
this._clip, base.paint, clipBehavior: this.clipBehavior);
1020-
base.paint(context, offset);
10211020
}
10221021
}
10231022

Runtime/ui/painting/canvas.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,24 +262,24 @@ public void drawArc(Rect rect, float startAngle, float sweepAngle, bool useCente
262262

263263
bool forceMoveTo = !useCenter;
264264
while (sweepAngle <= -Mathf.PI * 2) {
265-
path.addArc(rect, startAngle, -Mathf.PI, forceMoveTo);
265+
path.arcTo(rect, startAngle, -Mathf.PI, forceMoveTo);
266266
startAngle -= Mathf.PI;
267-
path.addArc(rect, startAngle, -Mathf.PI, false);
267+
path.arcTo(rect, startAngle, -Mathf.PI, false);
268268
startAngle -= Mathf.PI;
269269
forceMoveTo = false;
270270
sweepAngle += Mathf.PI * 2;
271271
}
272272

273273
while (sweepAngle >= Mathf.PI * 2) {
274-
path.addArc(rect, startAngle, Mathf.PI, forceMoveTo);
274+
path.arcTo(rect, startAngle, Mathf.PI, forceMoveTo);
275275
startAngle += Mathf.PI;
276-
path.addArc(rect, startAngle, Mathf.PI, false);
276+
path.arcTo(rect, startAngle, Mathf.PI, false);
277277
startAngle += Mathf.PI;
278278
forceMoveTo = false;
279279
sweepAngle -= Mathf.PI * 2;
280280
}
281281

282-
path.addArc(rect, startAngle, sweepAngle, forceMoveTo);
282+
path.arcTo(rect, startAngle, sweepAngle, forceMoveTo);
283283
if (useCenter) {
284284
path.close();
285285
}

Runtime/ui/painting/path.cs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,29 +181,47 @@ public void relativeMoveTo(float x, float y) {
181181
x + x0, y + y0,
182182
});
183183
}
184-
184+
185185
public void moveTo(float x, float y) {
186186
this._appendCommands(new[] {
187187
(float) PathCommand.moveTo,
188188
x, y,
189189
});
190-
}
190+
}
191+
191192

193+
public void relativeLineTo(float x, float y) {
194+
var x0 = this._commandx;
195+
var y0 = this._commandy;
196+
197+
this._appendCommands(new[] {
198+
(float) PathCommand.lineTo,
199+
x + x0, y + y0,
200+
});
201+
}
202+
192203
public void lineTo(float x, float y) {
193204
this._appendCommands(new[] {
194205
(float) PathCommand.lineTo,
195206
x, y,
196207
});
197208
}
198209

199-
public void bezierTo(float c1x, float c1y, float c2x, float c2y, float x, float y) {
210+
public void cubicTo(float c1x, float c1y, float c2x, float c2y, float x, float y) {
200211
this._appendCommands(new[] {
201212
(float) PathCommand.bezierTo,
202213
c1x, c1y, c2x, c2y, x, y,
203214
});
204215
}
216+
217+
public void relativeCubicTo(float c1x, float c1y, float c2x, float c2y, float x, float y) {
218+
var x0 = this._commandx;
219+
var y0 = this._commandy;
220+
221+
this.cubicTo(x0 + c1x, y0 + c1y, x0 + c2x, y0 + c2y, x0 + x, y0 + y);
222+
}
205223

206-
public void quadTo(float cx, float cy, float x, float y) {
224+
public void quadraticBezierTo(float cx, float cy, float x, float y) {
207225
var x0 = this._commandx;
208226
var y0 = this._commandy;
209227

@@ -214,6 +232,13 @@ public void quadTo(float cx, float cy, float x, float y) {
214232
x, y,
215233
});
216234
}
235+
236+
public void relativeQuadraticBezierTo(float cx, float cy, float x, float y) {
237+
var x0 = this._commandx;
238+
var y0 = this._commandy;
239+
240+
this.quadraticBezierTo(x0 + cx, y0 + cy, x0 + x, y0 + y);
241+
}
217242

218243
public void close() {
219244
this._appendCommands(new[] {
@@ -339,7 +364,7 @@ public void arcTo(float x1, float y1, float x2, float y2, float radius) {
339364
this.addArc(cx, cy, radius, a0, a1, dir);
340365
}
341366

342-
public void addArc(Rect rect, float startAngle, float sweepAngle, bool forceMoveTo = true) {
367+
public void arcTo(Rect rect, float startAngle, float sweepAngle, bool forceMoveTo = true) {
343368
var mat = Matrix3.makeScale(rect.width / 2, rect.height / 2);
344369
var center = rect.center;
345370
mat.postTranslate(center.dx, center.dy);
@@ -351,6 +376,10 @@ public void addArc(Rect rect, float startAngle, float sweepAngle, bool forceMove
351376
this._appendCommands(vals.ToArray());
352377
}
353378

379+
public void addArc(Rect rect, float startAngle, float sweepAngle) {
380+
this.arcTo(rect, startAngle, sweepAngle, true);
381+
}
382+
354383
public Path transform(Matrix3 mat) {
355384
Path ret = new Path();
356385

@@ -372,7 +401,7 @@ public Path transform(Matrix3 mat) {
372401
var res1 = mat.mapXY(this._commands[i + 1], this._commands[i + 2]);
373402
var res2 = mat.mapXY(this._commands[i + 3], this._commands[i + 4]);
374403
var res3 = mat.mapXY(this._commands[i + 5], this._commands[i + 6]);
375-
ret.bezierTo(res1.dx, res1.dy, res2.dx, res2.dy, res3.dx, res3.dy);
404+
ret.cubicTo(res1.dx, res1.dy, res2.dx, res2.dy, res3.dx, res3.dy);
376405
i += 7;
377406
break;
378407
case PathCommand.close:

Runtime/widgets/binding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void _handlePopRouteSub(bool result) {
6565
Application.Quit();
6666
return;
6767
}
68-
this._observers[idx].didPopRoute().Then(_handlePopRouteSub);
68+
this._observers[idx].didPopRoute().Then((Action<bool>) _handlePopRouteSub);
6969
}
7070
}
7171

0 commit comments

Comments
 (0)