Skip to content

Commit c5a3311

Browse files
committed
refac: half circle methods
1 parent fae4904 commit c5a3311

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

src/App.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
:size="600"
4343
half
4444
:angle="0"
45-
line-position="out 50"
46-
empty-line-position="out 0"
45+
line-position="out 40"
46+
empty-line-position="out 20"
4747
empty-color-fill="red"
4848
color-fill="green"
4949
empty-color="transparent"

src/components/Circle/HalfCircle.vue

+10-20
Original file line numberDiff line numberDiff line change
@@ -66,34 +66,24 @@ export default {
6666
return (this.radius * 2 * Math.PI) / 2;
6767
},
6868
path() {
69-
return ` M ${this.position}, ${this.options.size / 2} a ${this.radius},${this.radius} 0 1,1 ${this.radius * 2},0`;
69+
return this.getPath(this.radius);
7070
},
7171
fillPath() {
72-
return ` M ${this.fillPosition}, ${this.options.size / 2} a ${this.fillRadius},${this.fillRadius} 0 1,1 ${
73-
this.fillRadius * 2
74-
},0`;
72+
return this.getPath(this.fillRadius);
7573
},
7674
emptyPath() {
77-
return ` M ${this.emptyPosition}, ${this.options.size / 2} a ${this.emptyRadius},${this.emptyRadius} 0 1,1 ${
78-
this.emptyRadius * 2
79-
},0`;
75+
return this.getPath(this.emptyRadius);
8076
},
8177
emptyFillPath() {
82-
return ` M ${this.emptyFillPosition}, ${this.options.size / 2} a ${this.emptyFillRadius},${
83-
this.emptyFillRadius
84-
} 0 1,1 ${this.emptyFillRadius * 2},0`;
78+
return this.getPath(this.emptyFillRadius);
8579
},
86-
position() {
87-
return this.options.size / 2 - this.radius;
88-
},
89-
fillPosition() {
90-
return this.options.size / 2 - this.fillRadius;
91-
},
92-
emptyPosition() {
93-
return this.options.size / 2 - this.emptyRadius;
80+
},
81+
methods: {
82+
getPosition(radius) {
83+
return this.options.size / 2 - radius;
9484
},
95-
emptyFillPosition() {
96-
return this.options.size / 2 - this.emptyFillRadius;
85+
getPath(radius) {
86+
return ` M ${this.getPosition(radius)}, ${this.options.size / 2} a ${radius},${radius} 0 1,1 ${radius * 2},0`;
9787
},
9888
},
9989
};

0 commit comments

Comments
 (0)