1// Copyright 2013 The Flutter Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5part of engine; 6 7/// An implementation of [ui.Path] which is backed by an `SkPath`. 8/// 9/// The `SkPath` is required for `SkCanvas` methods which take a path. 10class SkPath implements ui.Path { 11 js.JsObject _skPath; 12 13 SkPath() { 14 _skPath = js.JsObject(canvasKit['SkPath']); 15 } 16 17 js.JsObject _makeSkRect(ui.Rect rect) { 18 return js.JsObject(canvasKit['LTRBRect'], 19 <double>[rect.left, rect.top, rect.right, rect.bottom]); 20 } 21 22 @override 23 ui.PathFillType fillType; 24 25 @override 26 void addArc(ui.Rect oval, double startAngle, double sweepAngle) { 27 throw 'addArc'; 28 } 29 30 @override 31 void addOval(ui.Rect oval) { 32 throw 'addOval'; 33 } 34 35 @override 36 void addPath(ui.Path path, ui.Offset offset, {Float64List matrix4}) { 37 throw 'addPath'; 38 } 39 40 @override 41 void addPolygon(List<ui.Offset> points, bool close) { 42 throw 'addPolygon'; 43 } 44 45 @override 46 void addRRect(ui.RRect rrect) { 47 final js.JsObject skRect = _makeSkRect(rrect.outerRect); 48 final List<num> radii = <num>[ 49 rrect.tlRadiusX, 50 rrect.tlRadiusY, 51 rrect.trRadiusX, 52 rrect.trRadiusY, 53 rrect.brRadiusX, 54 rrect.brRadiusY, 55 rrect.blRadiusX, 56 rrect.blRadiusY, 57 ]; 58 _skPath.callMethod('addRoundRect', <dynamic>[skRect, radii]); 59 } 60 61 @override 62 void addRect(ui.Rect rect) { 63 throw 'addRect'; 64 } 65 66 @override 67 void arcTo( 68 ui.Rect rect, double startAngle, double sweepAngle, bool forceMoveTo) { 69 throw 'arcTo'; 70 } 71 72 @override 73 void arcToPoint(ui.Offset arcEnd, 74 {ui.Radius radius = ui.Radius.zero, 75 double rotation = 0.0, 76 bool largeArc = false, 77 bool clockwise = true}) { 78 throw 'arcToPoint'; 79 } 80 81 @override 82 void close() { 83 throw 'close'; 84 } 85 86 @override 87 ui.PathMetrics computeMetrics({bool forceClosed = false}) { 88 throw 'computeMetrics'; 89 } 90 91 @override 92 void conicTo(double x1, double y1, double x2, double y2, double w) { 93 throw 'conicTo'; 94 } 95 96 @override 97 bool contains(ui.Offset point) { 98 throw 'contains'; 99 } 100 101 @override 102 void cubicTo( 103 double x1, double y1, double x2, double y2, double x3, double y3) { 104 throw 'cubicTo'; 105 } 106 107 @override 108 void extendWithPath(ui.Path path, ui.Offset offset, {Float64List matrix4}) { 109 throw 'extendWithPath'; 110 } 111 112 @override 113 ui.Rect getBounds() { 114 throw 'getBounds'; 115 } 116 117 @override 118 void lineTo(double x, double y) { 119 throw 'lineTo'; 120 } 121 122 @override 123 void moveTo(double x, double y) { 124 throw 'moveTo'; 125 } 126 127 @override 128 void quadraticBezierTo(double x1, double y1, double x2, double y2) { 129 throw 'quadraticBezierTo'; 130 } 131 132 @override 133 void relativeArcToPoint(ui.Offset arcEndDelta, 134 {ui.Radius radius = ui.Radius.zero, 135 double rotation = 0.0, 136 bool largeArc = false, 137 bool clockwise = true}) { 138 throw 'relativeArcToPoint'; 139 } 140 141 @override 142 void relativeConicTo(double x1, double y1, double x2, double y2, double w) { 143 throw 'relativeConicTo'; 144 } 145 146 @override 147 void relativeCubicTo( 148 double x1, double y1, double x2, double y2, double x3, double y3) { 149 throw 'relativeCubicTo'; 150 } 151 152 @override 153 void relativeLineTo(double dx, double dy) { 154 throw 'relativeLineTo'; 155 } 156 157 @override 158 void relativeMoveTo(double dx, double dy) { 159 throw 'relativeMoveTo'; 160 } 161 162 @override 163 void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2) { 164 throw 'relativeQuadraticBezierTo'; 165 } 166 167 @override 168 void reset() { 169 throw 'reset'; 170 } 171 172 @override 173 ui.Path shift(ui.Offset offset) { 174 throw 'shift'; 175 } 176 177 @override 178 List<Subpath> get subpaths => throw 'subpaths'; 179 180 @override 181 ui.Path transform(Float64List matrix4) { 182 throw 'transform'; 183 } 184 185 @override 186 // TODO: implement webOnlyPathAsCircle 187 Ellipse get webOnlyPathAsCircle => null; 188 189 @override 190 // TODO: implement webOnlyPathAsRect 191 ui.Rect get webOnlyPathAsRect => null; 192 193 @override 194 // TODO: implement webOnlyPathAsRoundedRect 195 ui.RRect get webOnlyPathAsRoundedRect => null; 196 197 @override 198 List webOnlySerializeToCssPaint() { 199 // TODO: implement webOnlySerializeToCssPaint 200 return null; 201 } 202} 203