File tree Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " slidev-addon-fancy-arrow " : minor
3
+ ---
4
+
5
+ Add roughness and seed props
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ const props = defineProps<{
19
19
arc? : number | string ;
20
20
arrowHeadType? : " line" | " polygon" ;
21
21
arrowHeadSize? : number | string ;
22
+ roughness? : number | string ;
23
+ seed? : number | string ;
22
24
}>();
23
25
24
26
const point1 = props .id1
@@ -37,6 +39,8 @@ const roughSvg = useRoughArrow({
37
39
centerPositionParam: Number (props .arc ?? 0 ),
38
40
arrowHeadType: props .arrowHeadType ?? " line" ,
39
41
arrowHeadSize: props .arrowHeadSize ? Number (props .arrowHeadSize ) : null ,
42
+ roughness: props .roughness ? Number (props .roughness ) : undefined ,
43
+ seed: props .seed ? Number (props .seed ) : undefined ,
40
44
});
41
45
</script >
42
46
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ export function useRoughArrow(props: {
46
46
width : number ;
47
47
arrowHeadType : "line" | "polygon" ;
48
48
arrowHeadSize : number | null ;
49
+ roughness ?: number ;
50
+ seed ?: number ;
49
51
twoWay : boolean ;
50
52
centerPositionParam : number ;
51
53
} ) {
@@ -56,17 +58,20 @@ export function useRoughArrow(props: {
56
58
width,
57
59
arrowHeadType,
58
60
arrowHeadSize,
61
+ roughness,
62
+ seed,
59
63
twoWay,
60
64
centerPositionParam,
61
65
} = props ;
62
-
63
66
const options = {
64
67
stroke : color ,
65
68
strokeWidth : width ,
66
69
fill : color ,
67
70
fillStyle : "solid" ,
68
- } ;
69
-
71
+ // We don't support the `bowing` param because it's not so effective for arc.
72
+ ...( roughness !== undefined && { roughness } ) ,
73
+ ...( seed !== undefined && { seed } ) ,
74
+ } as const ;
70
75
const svg = ref < SVGSVGElement > (
71
76
document . createElementNS ( "http://www.w3.org/2000/svg" , "svg" ) ,
72
77
) ;
Original file line number Diff line number Diff line change 1
1
---
2
+ mdc : true
3
+ ---
2
4
3
5
# Fancy Arrow
4
6
7
+ ## Slidev addon for drawing arrows with <span v-mark.red id =" fancy-styles " >fancy styles</span >,
8
+
9
+ <span v-click id =" rough-js " >powered by [ Rough.js] ( https://roughjs.com ) .</span >
10
+
11
+ <FancyArrow v-after id1 =" rough-js " pos1 =" bottomright " id2 =" fancy-styles " pos2 =" bottomleft " color =" red " width =" 2 " arc =" -0.3 " seed =" 1 " roughness =" 2 " />
12
+
5
13
---
6
14
7
15
# Demo
You can’t perform that action at this time.
0 commit comments