Skip to content

Commit 4986a65

Browse files
authored
Revert reverse arc direction (#32)
* Revert "Reverse the arc direction (#30)", use-rough-arrow.ts only This reverts commit b4bcfaa. * Update comment * Update slides.md * Fix slides.md * Add changeset
1 parent e29f880 commit 4986a65

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

.changeset/olive-otters-add.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"slidev-addon-fancy-arrow": minor
3+
---
4+
5+
[BREAKING] Revert the previous version

components/use-rough-arrow.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function useRoughArrow(props: {
101101
lineOptions,
102102
);
103103
const angle =
104-
Math.atan2(point2.y - point1.y, point2.x - point1.x) + Math.PI / 2;
104+
Math.atan2(point2.y - point1.y, point2.x - point1.x) - Math.PI / 2;
105105
return {
106106
svg,
107107
angle1: angle,
@@ -123,8 +123,8 @@ export function useRoughArrow(props: {
123123

124124
// Unit vector perpendicular to the chord.
125125
const n = {
126-
x: dy / chordLength,
127-
y: -dx / chordLength,
126+
x: -dy / chordLength,
127+
y: dx / chordLength,
128128
};
129129

130130
// Offset for the arc's center from the midpoint.
@@ -172,7 +172,7 @@ export function useRoughArrow(props: {
172172
// So we use .path() instead as below.
173173
const largeArcFlag =
174174
centerPositionParam < -1 || 1 < centerPositionParam ? 1 : 0;
175-
const sweepFlag = centerPositionParam > 0 ? 0 : 1;
175+
const sweepFlag = centerPositionParam > 0 ? 1 : 0;
176176
const svg = roughSvg.path(
177177
`M${point1.x} ${point1.y} A${R} ${R} 0 ${largeArcFlag} ${sweepFlag} ${point2.x} ${point2.y}`,
178178
lineOptions,
@@ -248,14 +248,14 @@ export function useRoughArrow(props: {
248248

249249
arrowHead2.setAttribute(
250250
"transform",
251-
`translate(${point2Ref.value.x},${point2Ref.value.y}) rotate(${(arcData.value.angle2 * 180) / Math.PI + (centerPositionParam >= 0 ? -90 : 90)})`,
251+
`translate(${point2Ref.value.x},${point2Ref.value.y}) rotate(${(arcData.value.angle2 * 180) / Math.PI + (centerPositionParam >= 0 ? 90 : -90)})`,
252252
);
253253
svg.value.appendChild(arrowHead2);
254254

255255
if (twoWay) {
256256
arrowHead1.setAttribute(
257257
"transform",
258-
`translate(${point1Ref.value.x},${point1Ref.value.y}) rotate(${(arcData.value.angle1 * 180) / Math.PI + (centerPositionParam >= 0 ? 90 : -90)})`,
258+
`translate(${point1Ref.value.x},${point1Ref.value.y}) rotate(${(arcData.value.angle1 * 180) / Math.PI + (centerPositionParam >= 0 ? -90 : 90)})`,
259259
);
260260
svg.value.appendChild(arrowHead1);
261261
}

slides.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,16 @@ mdc: true
172172

173173
# Arc
174174

175-
<code id="arc-start" absolute left-300px top-400px style="transform: translate(-50%, -50%);">#arc-start</code>
176-
<code id="arc-end" absolute left-300px top-100px style="transform: translate(-50%, -50%);">#arc-end</code>
175+
<code id="arc-start" absolute left-300px top-100px style="transform: translate(-50%, -50%);">#arc-start</code>
176+
<code id="arc-end" absolute left-300px top-400px style="transform: translate(-50%, -50%);">#arc-end</code>
177177

178-
<FancyArrow id1="arc-start" id2="arc-end" arc="1.5" color="red" />
179-
<FancyArrow id1="arc-start" id2="arc-end" arc="1.0" color="orange" />
180-
<FancyArrow id1="arc-start" id2="arc-end" arc="0.5" color="yellow" />
181-
<FancyArrow id1="arc-start" id2="arc-end" arc="0.0" color="green" />
182-
<FancyArrow id1="arc-start" id2="arc-end" arc="-0.5" color="blue" />
183-
<FancyArrow id1="arc-start" id2="arc-end" arc="-1.0" color="purple" />
184-
<FancyArrow id1="arc-start" id2="arc-end" arc="-1.5" color="pink" />
178+
<FancyArrow arc="1.5" id1="arc-start" pos1="bottom" id2="arc-end" pos2="top" color="red" />
179+
<FancyArrow arc="1.0" id1="arc-start" pos1="bottom" id2="arc-end" pos2="top" color="orange" />
180+
<FancyArrow arc="0.5" id1="arc-start" pos1="bottom" id2="arc-end" pos2="top" color="yellow" />
181+
<FancyArrow arc="0.0" id1="arc-start" pos1="bottom" id2="arc-end" pos2="top" color="green" />
182+
<FancyArrow arc="-0.5" id1="arc-start" pos1="bottom" id2="arc-end" pos2="top" color="blue" />
183+
<FancyArrow arc="-1.0" id1="arc-start" pos1="bottom" id2="arc-end" pos2="top" color="purple" />
184+
<FancyArrow arc="-1.5" id1="arc-start" pos1="bottom" id2="arc-end" pos2="top" color="pink" />
185185

186186
<Arrow x1="50" y1="450" x2="550" y2="450" />
187187

@@ -224,16 +224,16 @@ mdc: true
224224
<span id="bar">Bar</span>
225225
</div>
226226

227-
<FancyArrow v-click="1" forward:delay-100 id1="foo" pos1="bottomleft" id2="bar" pos2="topleft" color="red" width="2" arc="0.3" seed="1" roughness="2" >Hey</FancyArrow>
228-
<FancyArrow v-click="1" forward:delay-100 id2="foo" pos2="bottomright" id1="bar" pos1="topright" color="red" width="2" arc="0.3" seed="1" roughness="2" >
227+
<FancyArrow v-click="1" forward:delay-100 id1="foo" pos1="bottomright" id2="bar" pos2="topright" color="red" width="2" arc="0.3" seed="1" roughness="2" >Hey</FancyArrow>
228+
<FancyArrow v-click="1" forward:delay-100 id2="foo" pos2="bottomleft" id1="bar" pos1="topleft" color="red" width="2" arc="0.3" seed="1" roughness="2" >
229229
<span text-red>Ahoy</span>
230230
</FancyArrow>
231231

232232
<div v-click p-8 :class="$clicks === 0 ? 'translate-y--32' : $clicks === 1 ? 'translate-y--16' : ''">
233233
<span id="baz">Baz</span>
234234
</div>
235235

236-
<FancyArrow v-click="2" forward:delay-100 id1="bar" pos1="bottomleft" id2="baz" pos2="topleft" color="green" width="2" arc="0.3" seed="1" roughness="2" >
236+
<FancyArrow v-click="2" forward:delay-100 id1="bar" pos1="bottomright" id2="baz" pos2="topright" color="green" width="2" arc="0.3" seed="1" roughness="2" >
237237
<span text-green v-mark.green="2">Hola!</span>
238238
</FancyArrow>
239239
---

0 commit comments

Comments
 (0)