@@ -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
@@ -1538,6 +1566,23 @@ defmodule Scenic.Script do
1538
1566
]
1539
1567
end
1540
1568
1569
+ defp serialize_op ( { :arc , { cx , cy , r , a0 , a1 , dir } } ) do
1570
+ [
1571
+ <<
1572
+ @ op_arc :: 16 - big ,
1573
+ 0 :: 16
1574
+ >> ,
1575
+ <<
1576
+ cx :: float - 32 - big ,
1577
+ cy :: float - 32 - big ,
1578
+ r :: float - 32 - big ,
1579
+ a0 :: float - 32 - big ,
1580
+ a1 :: float - 32 - big ,
1581
+ dir :: 32 - big
1582
+ >>
1583
+ ]
1584
+ end
1585
+
1541
1586
defp serialize_op ( { :bezier_to , { cp1x , cp1y , cp2x , cp2y , x , y } } ) do
1542
1587
[
1543
1588
<<
@@ -2261,6 +2306,20 @@ defmodule Scenic.Script do
2261
2306
{ { :arc_to , { x1 , y1 , x2 , y2 , radius } } , bin }
2262
2307
end
2263
2308
2309
+ defp deserialize_op ( <<
2310
+ @ op_arc :: 16 - big ,
2311
+ 0 :: 16 ,
2312
+ cx :: float - 32 - big ,
2313
+ cy :: float - 32 - big ,
2314
+ r :: float - 32 - big ,
2315
+ a0 :: float - 32 - big ,
2316
+ a1 :: float - 32 - big ,
2317
+ dir :: 32 - big ,
2318
+ bin :: binary
2319
+ >> ) do
2320
+ { { :arc , { cx , cy , r , a0 , a1 , dir } } , bin }
2321
+ end
2322
+
2264
2323
defp deserialize_op ( <<
2265
2324
@ op_bezier_to :: 16 - big ,
2266
2325
0 :: 16 ,
0 commit comments