@@ -18,6 +18,7 @@ export const arc = defineComponent<'arc', typeof T.infer, {
1818 to : number
1919 startSide : number
2020 endSide : number
21+ division : number | undefined
2122} > ( ( attrs , context ) => {
2223 return {
2324 name : 'arc' ,
@@ -27,6 +28,7 @@ export const arc = defineComponent<'arc', typeof T.infer, {
2728 type : 'solid' ,
2829 } ,
2930 setup ( ) {
31+ const division = context . division ?? 1
3032 const container = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'g' )
3133 container . id = 'canvas-angle-arc'
3234 const angleValue = Math . abs ( ( context . to - context . from + 360 ) % 360 )
@@ -35,8 +37,8 @@ export const arc = defineComponent<'arc', typeof T.infer, {
3537 const length = Math . min ( context . startSide ?? 0 , context . endSide ?? 0 ) / 3
3638 const radFrom = context . from * Math . PI / 180
3739 const radTo = context . to * Math . PI / 180
38- const p1 = [ length * Math . cos ( radFrom ) , length * Math . sin ( radFrom ) ]
39- const p2 = [ length * Math . cos ( radTo ) , length * Math . sin ( radTo ) ]
40+ const p1 = [ length * Math . cos ( radFrom ) * division , length * Math . sin ( radFrom ) * division ]
41+ const p2 = [ length * Math . cos ( radTo ) * division , length * Math . sin ( radTo ) * division ]
4042 const line1 = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'line' )
4143 line1 . setAttribute ( 'x1' , '0' )
4244 line1 . setAttribute ( 'y1' , '0' )
@@ -53,8 +55,8 @@ export const arc = defineComponent<'arc', typeof T.infer, {
5355 line2 . setAttribute ( 'stroke' , theme . pallete ( 'primary' ) )
5456 line2 . setAttribute ( 'stroke-width' , '1' )
5557 line2 . setAttribute ( 'stroke-dasharray' , resolveDasharray ( attrs . type . value ) )
56- const l1 = [ length * 0.6 * Math . cos ( radFrom ) , length * 0.6 * Math . sin ( radFrom ) ]
57- const l2 = [ length * 0.6 * Math . cos ( radTo ) , length * 0.6 * Math . sin ( radTo ) ]
58+ const l1 = [ length * 0.6 * Math . cos ( radFrom ) * division , length * 0.6 * Math . sin ( radFrom ) * division ]
59+ const l2 = [ length * 0.6 * Math . cos ( radTo ) * division , length * 0.6 * Math . sin ( radTo ) * division ]
5860 const l3 = [ l1 [ 0 ] + ( l2 [ 0 ] ) , l1 [ 1 ] + ( l2 [ 1 ] ) ]
5961 const lPath = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'path' )
6062 lPath . setAttribute ( 'd' , `M ${ l1 [ 0 ] } ${ l1 [ 1 ] } L ${ l3 [ 0 ] } ${ l3 [ 1 ] } L ${ l2 [ 0 ] } ${ l2 [ 1 ] } ` )
@@ -79,16 +81,16 @@ export const arc = defineComponent<'arc', typeof T.infer, {
7981 else {
8082 const path = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'path' )
8183 path . id = 'angle-arc'
82- path . setAttribute ( 'd' , describeArc ( [ 0 , 0 ] , Math . min ( context . startSide ?? 0 , context . endSide ?? 0 ) / 3 , context . from , context . to ) )
84+ path . setAttribute ( 'd' , describeArc ( [ 0 , 0 ] , Math . min ( context . startSide ?? 0 , context . endSide ?? 0 ) / 3 * division , context . from , context . to ) )
8385 path . setAttribute ( 'stroke' , theme . pallete ( 'primary' ) )
8486 path . setAttribute ( 'fill' , 'none' )
8587 path . setAttribute ( 'stroke-dasharray' , resolveDasharray ( attrs . type . value ) )
8688 const texElement = generateTexNode ( attrs . value ?. value )
8789 const length = Math . min ( context . startSide ?? 0 , context . endSide ?? 0 ) / 3
8890 const angle = context . from + ( context . to - context . from ) / 2
8991 const position = [
90- length * Math . cos ( angle * Math . PI / 180 ) ,
91- length * Math . sin ( angle * Math . PI / 180 ) ,
92+ length * Math . cos ( angle * Math . PI / 180 ) * division ,
93+ length * Math . sin ( angle * Math . PI / 180 ) * division ,
9294 ]
9395 const texContainer = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'g' )
9496 texContainer . setAttribute ( 'transform' , `translate(${ position [ 0 ] } , ${ position [ 1 ] } )` )
0 commit comments