@@ -202,6 +202,7 @@ defmodule Scenic.Script do
202
202
@ op_sector 0x2F
203
203
@ op_circle 0x30
204
204
@ op_ellipse 0x31
205
+ @ op_arc 0x32
205
206
206
207
@ op_push_state 0x40
207
208
@ op_pop_state 0x41
@@ -829,6 +830,33 @@ defmodule Scenic.Script do
829
830
[ { :ellipse , { radius0 , radius1 } } | ops ]
830
831
end
831
832
833
+ @ doc """
834
+ Adds a new **circle arc** shaped segment to the path.
835
+
836
+ This adds to the current path. It does not fill or stroke anything.
837
+
838
+ ## Parameters
839
+
840
+ - cx, cy: The coordinates of the arc's center.
841
+ - r: the radius of the arc.
842
+ - a0, a1: the angles which the arc is drawn from angle a0 to a1, in radians.
843
+ - dir: s the direction of the arc sweep:
844
+ - `1` for counter clockwise sweep;
845
+ - `2` for clockwise sweep.
846
+ """
847
+ @ spec arc (
848
+ ops :: t ( ) ,
849
+ cx :: number ,
850
+ cy :: number ,
851
+ r :: number ,
852
+ a0 :: number ,
853
+ a1 :: number ,
854
+ dir :: integer
855
+ ) :: ops :: t ( )
856
+ def arc ( ops , cx , cy , r , a0 , a1 , dir ) do
857
+ [ { :arc , { cx , cy , r , a0 , a1 , dir } } | ops ]
858
+ end
859
+
832
860
@ doc """
833
861
Add a triangle to the current path.
834
862
@@ -1539,6 +1567,23 @@ defmodule Scenic.Script do
1539
1567
]
1540
1568
end
1541
1569
1570
+ defp serialize_op ( { :arc , { cx , cy , r , a0 , a1 , dir } } ) do
1571
+ [
1572
+ <<
1573
+ @ op_arc :: 16 - big ,
1574
+ 0 :: 16
1575
+ >> ,
1576
+ <<
1577
+ cx :: float - 32 - big ,
1578
+ cy :: float - 32 - big ,
1579
+ r :: float - 32 - big ,
1580
+ a0 :: float - 32 - big ,
1581
+ a1 :: float - 32 - big ,
1582
+ dir :: 32 - big
1583
+ >>
1584
+ ]
1585
+ end
1586
+
1542
1587
defp serialize_op ( { :bezier_to , { cp1x , cp1y , cp2x , cp2y , x , y } } ) do
1543
1588
[
1544
1589
<<
@@ -2263,6 +2308,20 @@ defmodule Scenic.Script do
2263
2308
{ { :arc_to , { x1 , y1 , x2 , y2 , radius } } , bin }
2264
2309
end
2265
2310
2311
+ defp deserialize_op ( <<
2312
+ @ op_arc :: 16 - big ,
2313
+ 0 :: 16 ,
2314
+ cx :: float - 32 - big ,
2315
+ cy :: float - 32 - big ,
2316
+ r :: float - 32 - big ,
2317
+ a0 :: float - 32 - big ,
2318
+ a1 :: float - 32 - big ,
2319
+ dir :: 32 - big ,
2320
+ bin :: binary
2321
+ >> ) do
2322
+ { { :arc , { cx , cy , r , a0 , a1 , dir } } , bin }
2323
+ end
2324
+
2266
2325
defp deserialize_op ( <<
2267
2326
@ op_bezier_to :: 16 - big ,
2268
2327
0 :: 16 ,
0 commit comments