-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
117 lines (107 loc) · 5.23 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css">
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.0"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.9.1/d3.min.js"></script>
<title>Document</title>
</head>
<body>
<div id="app">
<svg id="svg" ref="svg" xmlns="http://www.w3.org/2000/svg" :view-box.camel="viewBox">
<defs>
<g id="svg-group">
<template v-for="e in layer.elements">
<path v-if="e.type=='path'" :d="e.d" :style="estyle(e)" class="path" />
</template>
<path v-if="current.type=='path'" :d="pathd(current.points)" :style="estyle(current)" class="path" />
</g>
</defs>
<transition enter-active-class="fadeIn animated" leave-active-class="fadeOut animated">
<template v-if="showMarks">
<g v-if="layer.mirror" id="svg-marks" :transform="transform">
<line v-for="i in layer.repeat*2" :transform="rotatePart(i, layer.repeat*2)" stroke="#ccc" stroke-width="1" x1="0" y1="0" x2="1000" y2="0"></line>
</g>
<g v-else id="svg-marks" :transform="transform">
<line v-if="layer.repeat>1" v-for="i in layer.repeat" :transform="rotatePart(i, layer.repeat)" stroke="#ccc" stroke-width="1" x1="0" y1="0" x2="1000" y2="0"></line>
</g>
</template>
</transition>
<g id="svg-mandala" :transform="transform">
<g id="svg-layer">
<template v-for="i in layer.repeat">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#svg-group"
:transform="rotatePart(i, layer.repeat)"></use>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#svg-group"
:transform="rotatePart(i, layer.repeat)+' scale(1,-1)'" v-if="layer.mirror"></use>
</template>
</g>
</g>
</svg>
<div id="overlay" v-on:mousedown="onMouseDown" v-on:mousemove="onMouseMove" v-on:mouseup="onMouseEnd"
v-on:mouseleave="onMouseEnd" v-on:wheel="onMouseWheel" v-on:touchstart="onTouchStart" v-on:touchmove="onTouchMove"
v-on:touchend="onTouchEnd" v-on:touchleave="onTouchEnd"></div>
<div id="toolbar">
<div class="tbtn tbtn-clear" @click="onReset">
<i class="ibtn far fa-file"></i>
</div>
<div class="tbtn tbtn-undo" @click="onCtrlZ">
<i class="ibtn fas fa-undo"></i>
</div>
<div class="tbtn tbtn-color" @click="showPalette=!showPalette">
<div id="color" :style="{ 'background-color': strokeColor }"></div>
<transition enter-active-class="fadeIn animated" leave-active-class="fadeOut animated">
<ul v-if="showPalette" class="colors toggle" @click.stop>
<li v-for="color in palette" @click.stop="strokeColor=color;showPalette=false;"
:style="{ 'background-color': color }" :class="{ active: strokeColor==color }"></li>
</ul>
</transition>
</div>
<div class="tbtn tbtn-stroke" @click="showStroke=!showStroke">
<i class="ibtn fas fa-pencil-alt"></i>
<transition enter-active-class="fadeIn animated" leave-active-class="fadeOut animated">
<div v-if="showStroke" id="stroke" class="toggle" @click.stop>
<div>Stroke width : {{ strokeWidth }}px</div>
<input v-model="strokeWidth" type="range" min="0.2" max="20" step="0.2" class="custom-range">
<div>Precision : {{ strokePrecision }}px</div>
<input v-model="strokePrecision" type="range" min="1" max="100" class="custom-range">
</div>
</transition>
</div>
<div class="tbtn tbtn-zoomout" @click="zoomOut">
<i class="ibtn fas fa-search-minus"></i>
</div>
<div id="zoom-info">{{ zoom }} %</div>
<div class="tbtn tbtn-zoomin" @click="zoomIn">
<i class="ibtn fas fa-search-plus"></i>
</div>
<div class="tbtn tbtn-layer" @click="showLayer=!showLayer">
<i class="ibtn fas fa-cog"></i>
<transition enter-active-class="fadeIn animated" leave-active-class="fadeOut animated">
<div v-if="showLayer" id="layer" class="toggle" @click.stop>
<switch-btn v-model="showMarks" id="showMarks" label="Show marks"></switch-btn>
<switch-btn v-model="layer.mirror" id="mirror" label="Mirror"></switch-btn>
<div class="form-group">
<label for="repeat">Repeat : {{ repeat }}</label>
<input v-model="repeat" id="repeat" type="range" min="1" max="20" step="1" class="custom-range">
</div>
</div>
</transition>
</div>
</div>
</div>
<script type="x-template" id="switchBtn">
<div class="custom-control custom-switch">
<input type="checkbox" :checked="value" @input="$emit('input', $event.target.checked)" class="custom-control-input" :id="id">
<label :for="id" class="custom-control-label">{{ label }}</label>
</div>
</script>
<script src="./script.js"></script>
</body>
</html>