Просмотр исходного кода

change ellipse to be default

dev_h
Finn Böger 5 лет назад
Родитель
Сommit
c051d6b903

+ 1
- 1
client-data/board.html Просмотреть файл

84
 	<script src="tools/pencil/pencil.js"></script>
84
 	<script src="tools/pencil/pencil.js"></script>
85
 	<script src="tools/line/line.js"></script>
85
 	<script src="tools/line/line.js"></script>
86
 	<script src="tools/rect/rect.js"></script>
86
 	<script src="tools/rect/rect.js"></script>
87
-	<script src="tools/circle/circle.js"></script>
87
+	<script src="tools/ellipse/ellipse.js"></script>
88
 	<script src="tools/text/text.js"></script>
88
 	<script src="tools/text/text.js"></script>
89
 	<script src="tools/eraser/eraser.js"></script>
89
 	<script src="tools/eraser/eraser.js"></script>
90
 	<script src="tools/hand/hand.js"></script>
90
 	<script src="tools/hand/hand.js"></script>

client-data/tools/circle/circle.css → client-data/tools/ellipse/ellipse.css Просмотреть файл


client-data/tools/circle/circle.js → client-data/tools/ellipse/ellipse.js Просмотреть файл

26
 
26
 
27
 (function () { //Code isolation
27
 (function () { //Code isolation
28
     //Indicates the id of the shape the user is currently drawing or an empty string while the user is not drawing
28
     //Indicates the id of the shape the user is currently drawing or an empty string while the user is not drawing
29
-    let curshape = "Circle";
30
-    const icons = ["tools/circle/icon-circle.svg", "tools/circle/icon-ellipse.svg"];
29
+    let curshape = "Ellipse";
30
+    const icons = ["tools/ellipse/icon-ellipse.svg", "tools/ellipse/icon-circle.svg"];
31
     let end=false,
31
     let end=false,
32
         curId = "",
32
         curId = "",
33
         curUpdate = { //The data of the message that will be sent for every new point
33
         curUpdate = { //The data of the message that will be sent for every new point
46
         //Prevent the press from being interpreted by the browser
46
         //Prevent the press from being interpreted by the browser
47
         evt.preventDefault();
47
         evt.preventDefault();
48
 
48
 
49
-        curId = Tools.generateUID("c"); //"c" for circle
49
+        curId = Tools.generateUID("e"); //"e" for ellipse
50
 
50
 
51
         Tools.drawAndSend({
51
         Tools.drawAndSend({
52
-            'type': 'circle',
52
+            'type': 'ellipse',
53
             'id': curId,
53
             'id': curId,
54
             'shape': curshape,
54
             'shape': curshape,
55
             'color': Tools.getColor(),
55
             'color': Tools.getColor(),
93
     function draw(data) {
93
     function draw(data) {
94
         Tools.drawingEvent=true;
94
         Tools.drawingEvent=true;
95
         switch (data.type) {
95
         switch (data.type) {
96
-            case "circle":
96
+            case "ellipse":
97
                 createShape(data);
97
                 createShape(data);
98
                 break;
98
                 break;
99
             case "update":
99
             case "update":
129
     }
129
     }
130
 
130
 
131
     function updateShape(shape, data, circle) {
131
     function updateShape(shape, data, circle) {
132
-        console.log(data);
133
         shape.cx.baseVal.value = Math.round((data['x2'] + data['x'])/2);
132
         shape.cx.baseVal.value = Math.round((data['x2'] + data['x'])/2);
134
         shape.cy.baseVal.value = Math.round((data['y2'] + data['y'])/2);
133
         shape.cy.baseVal.value = Math.round((data['y2'] + data['y'])/2);
135
         if (circle) {
134
         if (circle) {
145
 
144
 
146
     function toggle(elem){
145
     function toggle(elem){
147
         let index = 0;
146
         let index = 0;
148
-        if (curshape === "Circle") {
149
-            curshape = "Ellipse";
147
+        if (curshape === "Ellipse") {
148
+            curshape = "Circle";
150
             index = 1;
149
             index = 1;
151
         } else {
150
         } else {
152
-            curshape = "Circle";
151
+            curshape = "Ellipse";
153
         }
152
         }
154
         elem.getElementsByClassName("tool-icon")[0].src = icons[index];
153
         elem.getElementsByClassName("tool-icon")[0].src = icons[index];
155
         elem.getElementsByClassName("tool-name")[0].textContent = curshape;
154
         elem.getElementsByClassName("tool-name")[0].textContent = curshape;
157
 
156
 
158
 
157
 
159
     Tools.add({ //The new tool
158
     Tools.add({ //The new tool
160
-        "name": "Circle",
159
+        "name": "Ellipse",
161
         "shortcut": "c",
160
         "shortcut": "c",
162
         "listeners": {
161
         "listeners": {
163
             "press": start,
162
             "press": start,
168
         "toggle": toggle,
167
         "toggle": toggle,
169
         "mouseCursor": "crosshair",
168
         "mouseCursor": "crosshair",
170
         "icon": icons[0],
169
         "icon": icons[0],
171
-        "stylesheet": "tools/circle/circle.css"
170
+        "stylesheet": "tools/ellipse/ellipse.css"
172
     });
171
     });
173
 
172
 
174
 })(); //End of code isolation
173
 })(); //End of code isolation

client-data/tools/circle/icon-circle.svg → client-data/tools/ellipse/icon-circle.svg Просмотреть файл


client-data/tools/circle/icon-ellipse.svg → client-data/tools/ellipse/icon-ellipse.svg Просмотреть файл


+ 1
- 1
server/createSVG.js Просмотреть файл

57
 			"L" + el.x + " " + el.y;
57
 			"L" + el.x + " " + el.y;
58
 		return renderPath(el, pathstring);
58
 		return renderPath(el, pathstring);
59
 	},
59
 	},
60
-	"Circle": function (el) {
60
+	"Ellipse": function (el) {
61
 		const cx = Math.round((el.x2 + el.x)/2);
61
 		const cx = Math.round((el.x2 + el.x)/2);
62
 		const cy = Math.round((el.y2 + el.y)/2);
62
 		const cy = Math.round((el.y2 + el.y)/2);
63
 		let rx, ry;
63
 		let rx, ry;

Загрузка…
Отмена
Сохранить