added orientation icon to the web app

This commit is contained in:
Simon Pirkelmann 2020-09-25 00:37:10 +02:00
parent 4baeace2ee
commit 54f0948a5f
4 changed files with 50 additions and 5 deletions

2
app.py
View File

@ -163,7 +163,7 @@ def hello_world():
if request.method == 'GET': if request.method == 'GET':
robot = players[player_id].robot robot = players[player_id].robot
if robot is not None: if robot is not None:
robot_pos = (robot.x, robot.y) robot_pos = (robot.x, robot.y, robot.orientation)
else: else:
robot_pos = None robot_pos = None
return render_template('drag_example.html', cmds=player_hand, player_id=player_id, robot_pos=robot_pos) return render_template('drag_example.html', cmds=player_hand, player_id=player_id, robot_pos=robot_pos)

BIN
static/orientation.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -18,6 +18,30 @@
cursor: move; cursor: move;
} }
.rotate90 {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
.rotate180 {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-o-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.rotate270 {
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}
.card0 { left: 0; top: 0; background-color: #E74C3C; } .card0 { left: 0; top: 0; background-color: #E74C3C; }
.card1 { left: 100px; top: 0; background-color: #8E44AD; } .card1 { left: 100px; top: 0; background-color: #8E44AD; }
.card2 { left: 200px; top: 0; background-color: #5DADE2; } .card2 { left: 200px; top: 0; background-color: #5DADE2; }

View File

@ -26,23 +26,27 @@
</div> </div>
{% if robot_pos is none %}
<div class="row"> <div class="row">
{% if robot_pos is none %}
<label for="inputRobotX">X:</label> <label for="inputRobotX">X:</label>
<input type="number" id="inputRobotX" name="robot_x" min="1" max="12" value="5"> <input type="number" id="inputRobotX" name="robot_x" min="1" max="12" value="5">
<label for="inputRobotY">Y:</label> <label for="inputRobotY">Y:</label>
<input type="number" id="inputRobotY" name="robot_y" min="1" max="6" value="3"> <input type="number" id="inputRobotY" name="robot_y" min="1" max="6" value="3">
</div>
<img id="orientation" src="/static/orientation.png" alt="0">
{% else %} {% else %}
<div class="row">
<label for="inputRobotX">X:</label> <label for="inputRobotX">X:</label>
<input type="number" id="inputRobotX" name="robot_x" min="1" max="12" value="{{ robot_pos[0] }}" readonly> <input type="number" id="inputRobotX" name="robot_x" min="1" max="12" value="{{ robot_pos[0] }}" readonly>
<label for="inputRobotY">Y:</label> <label for="inputRobotY">Y:</label>
<input type="number" id="inputRobotY" name="robot_y" min="1" max="6" value="{{ robot_pos[1] }}" readonly> <input type="number" id="inputRobotY" name="robot_y" min="1" max="6" value="{{ robot_pos[1] }}" readonly>
</div>
<img id="orientation" src="/static/orientation.png" name="{{ robot_pos[2] }}">
{% endif %} {% endif %}
</div>
</div><!-- container --> </div><!-- container -->
@ -61,6 +65,23 @@
var box = $(".box"); var box = $(".box");
var mainCanvas = $(".main-canvas"); var mainCanvas = $(".main-canvas");
var orientation_icon = $("#orientation");
orientation_icon.click(function () {
if (this.alt === "0") {
this.alt = "90";
}
else if (this.alt === "90") {
this.alt = "180";
}
else if (this.alt === "180") {
this.alt = "270";
}
else if (this.alt === "270") {
this.alt = "0";
}
$(this).css({'transform' : 'rotate('+ this.alt +'deg)'});
});
$("#btnSubmit").click(function () { $("#btnSubmit").click(function () {