Skip to content

Commit

Permalink
a cool compass
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmmdshirazi committed May 3, 2019
1 parent 7cead3e commit 9551b0e
Showing 1 changed file with 69 additions and 6 deletions.
75 changes: 69 additions & 6 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,37 @@ Window {

/// move the compass

compassInd.x = Math.sin(Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 - compassInd.height/2) + area.width/2 - compassInd.width/2
compassInd.y = Math.cos(Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 - compassInd.height/2) + area.width/2 - compassInd.height/2
compassInd.rotation = -compass[0] - 180
compassIndN.x = Math.sin(Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 - compassIndN.height/2) + area.width/2 - compassIndN.width/2
compassIndN.y = Math.cos(Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 - compassIndN.height/2) + area.width/2 - compassIndN.height/2
compassIndN.rotation = -compass[0] - 180

north.x = Math.sin(Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 + compassInd.height/2) + area.width/2 - north.width/2
north.y = Math.cos(Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 + compassInd.height/2) + area.width/2 - north.height/2
compassIndS.x = Math.sin(compass[0]*(Math.PI/180)) * (area.width/2 - compassIndN.height/2) + area.width/2 - compassIndN.width/2
compassIndS.y = Math.cos(compass[0]*(Math.PI/180)) * (area.width/2 - compassIndN.height/2) + area.width/2 - compassIndN.height/2
compassIndS.rotation = -compass[0]

compassIndW.x = Math.sin(Math.PI/2 + compass[0]*(Math.PI/180)) * (area.width/2 - compassIndN.height/2) + area.width/2 - compassIndN.width/2
compassIndW.y = Math.cos(Math.PI/2 + compass[0]*(Math.PI/180)) * (area.width/2 - compassIndN.height/2) + area.width/2 - compassIndN.height/2
compassIndW.rotation = -compass[0] - 90

compassIndE.x = Math.sin(Math.PI/2 + Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 - compassIndN.height/2) + area.width/2 - compassIndN.width/2
compassIndE.y = Math.cos(Math.PI/2 + Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 - compassIndN.height/2) + area.width/2 - compassIndN.height/2
compassIndE.rotation = -compass[0] - 270

north.x = Math.sin(Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 + compassIndN.height/2) + area.width/2 - north.width/2
north.y = Math.cos(Math.PI + compass[0]*(Math.PI/180)) * (area.width/2 + compassIndN.height/2) + area.width/2 - north.height/2
north.rotation = -compass[0] - 180

south.x = Math.sin(compass[0]*(Math.PI/180)) * (area.width/2 + compassIndN.height/2) + area.width/2 - north.width/2
south.y = Math.cos(compass[0]*(Math.PI/180)) * (area.width/2 + compassIndN.height/2) + area.width/2 - north.height/2
south.rotation = -compass[0]

east.x = Math.sin(Math.PI/2 + compass[0]*(Math.PI/180)) * (area.width/2 + compassIndN.height/2) + area.width/2 - north.width/2
east.y = Math.cos(Math.PI/2 + compass[0]*(Math.PI/180)) * (area.width/2 + compassIndN.height/2) + area.width/2 - north.height/2
east.rotation = -compass[0] - 270

west.x = Math.sin(Math.PI + Math.PI/2 + compass[0]*(Math.PI/180)) * (area.width/2 + compassIndN.height/2) + area.width/2 - north.width/2
west.y = Math.cos(Math.PI + Math.PI/2 + compass[0]*(Math.PI/180)) * (area.width/2 + compassIndN.height/2) + area.width/2 - north.height/2
west.rotation = -compass[0] - 90
}
}

Expand Down Expand Up @@ -139,7 +163,34 @@ Window {
radius: width/2
}
Rectangle {
id: compassInd
id: compassIndN
x: parent.width/2
y: 0
rotation: 0
width: 5
height: 35
color: "#f40b0b"
}
Rectangle {
id: compassIndS
x: parent.width/2
y: 0
rotation: 0
width: 5
height: 35
color: "#f40b0b"
}
Rectangle {
id: compassIndW
x: parent.width/2
y: 0
rotation: 0
width: 5
height: 35
color: "#f40b0b"
}
Rectangle {
id: compassIndE
x: parent.width/2
y: 0
rotation: 0
Expand All @@ -151,6 +202,18 @@ Window {
id: north
text: qsTr("N")
}
Text {
id: south
text: qsTr("S")
}
Text {
id: west
text: qsTr("W")
}
Text {
id: east
text: qsTr("E")
}
}


Expand Down

0 comments on commit 9551b0e

Please sign in to comment.