Versió 2025

This commit is contained in:
2026-05-08 19:50:22 +02:00
commit ddf72f37d6
123 changed files with 8809 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
# Agility Maps v2
## `/static/` Virtual static files directory
### About
This is a virtual directory of the /static path.
### Contents
- `public/`*` -> /public`*
- `ui/`*` -> /ui/`*
+1
View File
@@ -0,0 +1 @@
../public
Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

+1
View File
@@ -0,0 +1 @@
../ui
+664
View File
@@ -0,0 +1,664 @@
body {
background: #555555;
margin: 0;
padding: 0;
font-size: 10px;
font-family: Tahoma;
color: #dddddd;
background-image: url("/static/public/fondu.png");
background-repeat: repeat-x;
}
#logo {
position: absolute;
top: 0px;
left: 16px;
z-index: 100;
}
#titreLogo {
position: absolute;
top: 7px;
left: 700px;
z-index: 100;
}
#medaille {
position: absolute;
top: 55px;
left: 53px;
z-index: 100;
}
.barreTitre {
font-family: Georgia;
height: 5px;
width: 100%;
position: absolute;
color: #99ddff;
padding-left: 80px;
font-size: 20px;
z-index: 10;
}
.titleText {
float: left;
font-size: 20px;
}
.subtitle {
float: left;
font-size: 10px;
}
.barreOptions {
height: 61px;
/*width: 900px;*/
width: 830px;
position: absolute;
float: left;
left: 0px;
padding-left: 120px;
top: 26px;
font-size: 11px;
z-index: 10;
}
#blocOParam {
text-align: center;
}
#contentBlocOParam {
margin-top: -3px;
text-align: center;
}
#blocOObst {
text-align: center;
}
#contentBlocOObst {
margin-top: -3px;
text-align: center;
}
#blocOTrj {
text-align: center;
}
#contentBlocOTrj {
margin-top: -3px;
text-align: center;
}
#blocOCon {
text-align: center;
}
#contentBlocOCon {
margin-top: -3px;
text-align: center;
}
#blocOCou {
text-align: center;
}
#contentBlocOColor {
margin-top: -3px;
text-align: center;
}
#blocOSav {
text-align: center;
}
#contentBlocOSav {
margin-top: -3px;
text-align: center;
}
#blocOImp {
text-align: center;
}
#contentBlocOImp {
margin-top: -3px;
text-align: center;
}
#blocOLangue {
text-align: center;
}
#contentBlocOLangue {
margin-top: -3px;
text-align: center;
}
.blocOptions:hover,
.blocOptionsSel {
color: #99ddff;
border-left: solid #444444 1px;
border-right: solid #444444 1px;
border-top: solid #444444 1px;
float: left;
position: relative;
height: 55px;
margin-top: -5px;
padding-top: 5px;
width: 85px;
background-image: -webkit-linear-gradient(top, #aaaaaa 0%, #727272 100%);
background-image: -moz-linear-gradient(top, #aaaaaa 0%, #727272 100%);
background-image: -ms-linear-gradient(top, #aaaaaa 0%, #727272 100%);
background-image: -o-linear-gradient(top, #aaaaaa 0%, #727272 100%);
background-image: linear-gradient(top, #aaaaaa 0%, #727272 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#AAAAAA',endColorstr='#777777', GradientType=0);
}
.blocOptions {
border-left: solid #444444 1px;
border-right: solid #444444 1px;
border-top: solid #444444 1px;
float: left;
position: relative;
height: 55px;
width: 85px;
padding-top: 5px;
background-image: -webkit-linear-gradient(top, #888888 0%, #555555 100%);
background-image: -moz-linear-gradient(top, #888888 0%, #555555 100%);
background-image: -ms-linear-gradient(top, #888888 0%, #555555 100%);
background-image: -o-linear-gradient(top, #888888 0%, #555555 100%);
background-image: linear-gradient(top, #888888 0%, #555555 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#555555',endColorstr='#888888', GradientType=0);
}
.barreInfo {
height: 30px;
width: 900px;
background: #777777;
position: absolute;
float: left;
left: 0px;
top: 58px;
z-index: 12;
padding-left: 120px;
background-image: -webkit-linear-gradient(top, #777777 0%, #555555 100%);
background-image: -moz-linear-gradient(top, #777777 0%, #555555 100%);
background-image: -ms-linear-gradient(top, #777777 0%, #555555 100%);
background-image: -o-linear-gradient(top, #777777 0%, #555555 100%);
background-image: linear-gradient(top, #777777 0%, #555555 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#555555',endColorstr='#727272', GradientType=0);
}
.barreOutil {
position: absolute;
bottom: 0px;
top: 88px;
width: 120px;
left: 0px;
background: #777777;
height: 600px;
z-index: 8;
background-image: -webkit-linear-gradient(
right top,
#555555 0%,
#727272 100%
);
background-image: -moz-linear-gradient(right top, #555555 0%, #727272 100%);
background-image: -ms-linear-gradient(right top, #555555 0%, #727272 100%);
background-image: -o-linear-gradient(right top, #555555 0%, #727272 100%);
background-image: linear-gradient(right top, #555555 0%, #727272 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#727272',endColorstr='#555555', GradientType=1);
}
#barreOutilCache {
position: absolute;
bottom: 0px;
top: 88px;
width: 15px;
left: 95px;
background: #777777;
z-index: 8;
color: white;
background-image: -webkit-linear-gradient(
right top,
#555555 0%,
#727272 100%
);
background-image: -moz-linear-gradient(right top, #555555 0%, #727272 100%);
background-image: -ms-linear-gradient(right top, #555555 0%, #727272 100%);
background-image: -o-linear-gradient(right top, #555555 0%, #727272 100%);
background-image: linear-gradient(right top, #555555 0%, #727272 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#727272',endColorstr='#555555', GradientType=1);
}
#barreTitreCache {
height: 15px;
width: 100%;
background: #777777;
position: absolute;
float: left;
left: 0px;
top: 88px;
z-index: 1000;
background-image: -webkit-linear-gradient(top, #777777 0%, #555555 100%);
background-image: -moz-linear-gradient(top, #777777 0%, #555555 100%);
background-image: -ms-linear-gradient(top, #777777 0%, #555555 100%);
background-image: -o-linear-gradient(top, #777777 0%, #555555 100%);
background-image: linear-gradient(top, #777777 0%, #555555 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#555555',endColorstr='#727272', GradientType=0);
}
.blocOutil {
margin: 5px;
}
.blocInfo {
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
padding-bottom: 5px;
border-bottom: solid #444444 1px;
float: top;
position: relative;
}
.blocInfo:hover {
background: #999999;
}
.titreBloc {
width: 100%;
float: top;
text-align: center;
border-top: solid #444444 1px;
}
.contenu {
position: relative;
float: left;
}
.boutonOutil {
-webkit-border-radius: 4;
-moz-border-radius: 4;
border-radius: 4px;
color: white;
font-size: 10px;
background: #999999;
border: solid #444444 1px;
/*text-decoration: none;*/
margin: 1px;
height: 50px;
width: 50px;
}
.ligneBarreOutil {
width: 100%;
}
.checkboxTable {
float: left;
text-align: left;
}
.boutonOutil:hover {
border: solid #99ddff 1px;
}
.haie {
background-image: url("/static/public/icons/obstacles/jump.png");
}
.poubelle {
background-image: url("/static/public/icons/trash.png");
background-repeat: no-repeat;
}
.num {
background-image: url("/static/public/icons/numbers/num1.png");
background-repeat: no-repeat;
}
.num2 {
background-image: url("/static/public/icons/numbers/num2.png");
background-repeat: no-repeat;
}
.num3 {
background-image: url("/static/public/icons/numbers/num3.png");
background-repeat: no-repeat;
}
.oxer {
background-image: url("/static/public/icons/obstacles/double-jump.png");
}
.mur {
background-image: url("/static/public/icons/obstacles/wall.png");
}
.longueur {
background-image: url("/static/public/icons/obstacles/long-jump.png");
}
.table {
background-image: url("/static/public/icons/obstacles/table.png");
}
.tunnel {
background-image: url("/static/public/icons/obstacles/tunnel.png");
}
.tunnel3 {
background-image: url("/static/public/icons/obstacles/tunnel3.png");
}
.cho {
background-image: url("/static/public/icons/obstacles/sock.png");
}
.slalom {
background-image: url("/static/public/icons/obstacles/slalom.png");
}
.slalom6 {
background-image: url("/static/public/icons/obstacles/slalom6.png");
}
.pne {
background-image: url("/static/public/icons/obstacles/tire.png");
}
.pal {
background-image: url("/static/public/icons/obstacles/A.png");
}
.bal {
background-image: url("/static/public/icons/obstacles/balance.png");
}
.pas {
background-image: url("/static/public/icons/obstacles/run.png");
}
.zoomP {
background-image: url("/static/public/icons/zoom/plus.png");
background-repeat: no-repeat;
background-position: center;
}
.zoomM {
background-image: url("/static/public/icons/zoom/minus.png");
background-repeat: no-repeat;
background-position: center;
}
.newTrj {
background-image: url("/static/public/icons/newtrj.png");
background-repeat: no-repeat;
background-position: center;
}
.dMilieu {
background-image: url("/static/public/icons/driver/mr.png");
background-repeat: no-repeat;
}
.gMilieu {
background-image: url("/static/public/icons/driver/ml.png");
background-repeat: no-repeat;
}
.dLong {
background-image: url("/static/public/icons/driver/lr.png");
background-repeat: no-repeat;
}
.gLong {
background-image: url("/static/public/icons/driver/ll.png");
background-repeat: no-repeat;
}
.dAvant {
background-image: url("/static/public/icons/driver/fr.png");
background-repeat: no-repeat;
}
.gAvant {
background-image: url("/static/public/icons/driver/fl.png");
background-repeat: no-repeat;
}
.neutre {
background-image: url("/static/public/icons/driver/neutral.png");
background-repeat: no-repeat;
}
.chien {
background-image: url("/static/public/icons/driver/dog.png");
background-repeat: no-repeat;
}
option {
font-size: 12px;
font-family: Tahoma;
background-color: #666666;
border: solid #444444 1px;
color: #dddddd;
}
select {
font-size: 12px;
font-family: Tahoma;
background-color: #666666;
border: solid #444444 1px;
color: #dddddd;
width: 105px;
}
input {
font-size: 12px;
font-family: Tahoma;
}
input[type="text"] {
background-color: #666666;
border: solid #111111 1px;
color: #dddddd;
float: left;
position: relative;
width: 100px;
margin-bottom: 3px;
}
.ligneCheckboxTable:hover {
background-color: grey;
}
.txtOption {
font-size: 10px;
font-family: Tahoma;
float: top;
position: relative;
padding-left: 4px;
padding-right: 4px;
}
.txtCheckbox {
float: left;
text-align: left;
}
.boutonImage {
font-size: 10px;
font-family: Tahoma;
float: top;
position: relative;
width: 100%;
padding: 4px;
margin-top: 4px;
}
.txtFb {
background-color: #ccc;
padding: 5px;
margin: 5px;
border: solid #444444 1px;
color: #dddddd;
}
#blocInfoLangueFr {
display: none;
}
#blocInfoLanguePt {
display: none;
}
#blocInfoLangueEn {
display: none;
}
#blocInfoLangueEs {
display: none;
}
#blocInfoLangueDe {
display: none;
}
#blocInfoLangueIt {
display: none;
}
#blocInfoLanguePl {
display: none;
}
#blocInfoLangueCt {
display: none;
}
#blocInfoLangueJp {
display: none;
}
#blocInfoLangueSe {
display: none;
}
#blocInfoLangueFi {
display: none;
}
#blocInfoLangueDa {
display: none;
}
#blocInfoLangueNo {
display: none;
}
#blocInfoLangueHu {
display: none;
}
#blocInfoLangueRu {
display: none;
}
#blocInfoColor {
display: none;
}
#blocInfoColorPerso {
display: none;
}
#blocInfoTraj {
display: none;
}
#blocInfoParam {
display: none;
}
#blocInfoDim2 {
display: none;
}
#blocInfoDim1 {
display: none;
}
#blocInfoSauvegarde {
display: none;
}
#blocInfoCon {
display: none;
}
.noStyle {
margin: 0;
padding: 0;
float: left;
display: block;
}
#contentCanvas {
position: absolute;
top: 90px;
left: 120px;
z-index: 340;
/*padding-top: 90px;
padding-left: 120px;*/
}
#canvas {
background: #ffffff;
z-index: 350;
}
.imageExport {
position: absolute;
left: 0px;
top: 0px;
visibility: visible;
z-index: 200;
}
#canvasimg {
visibility: hidden;
position: absolute;
left: 0px;
top: 40px;
z-index: 1000;
}
.imageNotExport {
display: none;
}
.fondExport {
color: white;
text-align: center;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
visibility: visible;
/* z-index: 400; */
z-index: 150;
}
.fondNoExport {
visibility: hidden;
}
.exempleCouleur {
width: 20px;
height: 15px;
background-color: white;
float: left;
display: block;
position: relative;
margin-left: 6px;
margin-right: 6px;
}
#texte {
position: relative;
float: left;
}
.colorSample {
width: 20px;
height: 15px;
float: left;
margin-right: 5px;
margin-left: 5px;
border: solid black 1px;
}
.miniColorSample {
width: 10px;
height: 15px;
float: left;
}
#color-white, #color-white-2 {
background-color: rgba(255, 255, 255, 1);
}
#color-blue, #color-blue-2 {
background-color: rgba(211, 228, 240, 1);
}
#color-green, #color-green-2 {
background-color: rgba(204, 255, 204, 1);
}
#color-blueObst {
background-color: rgba(34, 170, 255, 1);
}
#color-redObst {
background-color: rgba(204, 51, 0, 1);
}
#color-greyObst {
background-color: rgba(221, 221, 221, 1);
}
#color-black {
background-color: rgba(30, 30, 30, 1);
}
#color-pink {
background-color: rgba(249, 141, 228, 1);
}
#color-grey-con {
background-color: rgba(221, 221, 221, 1);
}
#color-red-con {
background-color: rgba(204, 51, 0, 1);
}
#color-blue-con {
background-color: rgba(34, 170, 255, 1);
}
#outils {
display: block;
}
#contentCanvas-col1 {
float:left;
}
#contentCanvas-col2 {
/* position: absolute; */
/* top: 0px; */
/* left: 870px; */
/* z-index: 340; */
width: 150px;
/*border: 1px solid white;*/
padding-left:10px;
overflow: hidden;
}
+36
View File
@@ -0,0 +1,36 @@
body {
background: #fff;
margin: 0;
padding: 0;
}
div {
display: none;
}
#canvasTxt {
display: none;
}
#canvasimg {
position: absolute;
left: 0px;
top: 0px;
display: block;
}
.imageExport {
position: absolute;
left: 0px;
top: 0px;
display: block;
}
.imageNotExport {
display: none;
}
.fondExport {
color: white;
display: block;
}
.fondNoExport {
display: none;
}
+459
View File
@@ -0,0 +1,459 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////AJOUT DES OBSTACLES////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function createItem(id) {
if (suppression) {
supprimerObstacle();
}
decalX = 0;
decalY = 0;
if (overTunnelId != -1) {
decalX = canvas_x - tbTunnels[id][nbArticulationTunnel * 2 + 1];
decalY = canvas_y - tbTunnels[id][nbArticulationTunnel * 2 + 2];
document.body.style.cursor = "pointer";
selTunnel = overTunnelId;
selPointTunnel = overPointTunnel;
} else if (overObject != -1) {
document.body.style.cursor = "move";
selObst = overObject;
decalX = getXCliquable(selObst) / 2;
decalY = getYCliquable(selObst) / 2;
setCanvasX(selObst, canvas_x - decalX);
setCanvasY(selObst, canvas_y - decalY);
genererParcours();
}
}
function ajouterHaie() {
var obstacle = new Array();
obstacle[0] = id; // id
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = (144 + 50 + 50) / pixel; //largeur X cliquable
obstacle[5] = 1; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "haie"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 90; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[5]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterPasserelle() {
var obstacle = new Array();
obstacle[0] = id;
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = 1140 / pixel; //largeur X cliquable
obstacle[5] = 30 / pixel; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "passerelle"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 0; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[4]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterBalancoire() {
var obstacle = new Array();
obstacle[0] = id;
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = 380 / pixel; //largeur X cliquable
obstacle[5] = 30 / pixel; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "balancoire"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 0; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[4]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterSlalom() {
var obstacle = new Array();
obstacle[0] = id;
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = (11 * 60) / pixel; //largeur X cliquable
obstacle[5] = 1; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "slalom"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 0; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[4]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterSlalom6() {
var obstacle = new Array();
obstacle[0] = id;
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = (11 * 28) / pixel; //largeur X cliquable
obstacle[5] = 1; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "slalom6"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 0; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[4]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterPalissade() {
var obstacle = new Array();
obstacle[0] = id;
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = 390 / pixel; //largeur X cliquable
obstacle[5] = 102 / pixel; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "palissade"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 0; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[4]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterChaussette() {
var obstacle = new Array();
obstacle[0] = id;
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = 73; //largeur X cliquable
obstacle[5] = 10; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "chaussette"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 0; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[4]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterLongueur() {
var obstacle = new Array();
obstacle[0] = id;
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = 150 / pixel; //largeur X cliquable
obstacle[5] = 150 / pixel; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "longueur"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 90; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[5]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterMur() {
var obstacle = new Array();
obstacle[0] = id; // id
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = (144 + LARGEUR_MUR_TOUR + LARGEUR_MUR_TOUR) / pixel; //largeur X cliquable
obstacle[5] = 4; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "mur"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 90; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[5]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterTable() {
var obstacle = new Array();
obstacle[0] = id; // id
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = DIM_TABLE; //largeur X cliquable
obstacle[5] = DIM_TABLE; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "table"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[4]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[4]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 0; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[4]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterOxer() {
var obstacle = new Array();
obstacle[0] = id; // id
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = (144 + 50 + 50) / pixel; //largeur X cliquable
obstacle[5] = 55 / pixel; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "oxer"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = -90; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[5]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterPneu() {
var obstacle = new Array();
obstacle[0] = id; // id
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[3] = "IMG"; // Image affiché à l'écran
obstacle[4] = 150 / pixel; //largeur X cliquable
obstacle[5] = 150 / pixel; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "pneu"; //type
obstacle[8] = obstacle[4]; // modif sur X pour trajectoires d'entrée
obstacle[9] = obstacle[5]; // modif sur Y pour trajectoires d'entrée
obstacle[10] = obstacle[4]; // modif sur X pour trajectoires de sortie
obstacle[11] = obstacle[5]; // modif sur Y pour trajectoires de sortie
obstacle[12] = 90; // modif sur angle pour trajectoires de sortie
obstacle[13] = obstacle[5]; // longueur pour trajectoires (X ou Y selon obstacle)
obstacle[14] = distObstTrajectoire; // distance de la trajectoire
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterConducteur(sens) {
var obstacle = new Array();
obstacle[0] = id; // id
obstacle[3] = sens; // sens
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[4] = 30; //largeur X cliquable
obstacle[5] = 30; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "conducteur"; //type
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterChien() {
var obstacle = new Array();
obstacle[0] = id; // id
obstacle[3] = 0; // sens
overObject = id;
obstacle[1] = canvas_x; // position X
obstacle[2] = canvas_y; // position Y
obstacle[4] = 30; //largeur X cliquable
obstacle[5] = 25; //hauteur Y cliquable
obstacle[6] = 0; //angle en degré
obstacle[7] = "chien"; //type
tbObst[id] = obstacle;
createItem(id);
id++;
genererParcours();
}
function ajouterTunnel(type) {
if (type == 3) {
var distMax = distMaxTunnel3;
} else {
var distMax = distMaxTunnel;
}
var tunnel = new Array();
tunnel[0] = idTunnel;
tunnel[nbArticulationTunnel * 2 + 3] = type;
overPointTunnel = nbArticulationTunnel;
overTunnelId = idTunnel;
for (var art = 0; art < nbArticulationTunnel; art++) {
tunnel[art * 2 + 1] = canvas_x + art * distMax; // position X premier point
tunnel[art * 2 + 2] = canvas_y; // position Y premier point
}
tbTunnels[idTunnel] = tunnel;
createItem(idTunnel);
idTunnel++;
genererParcours();
}
function ajouterNumero(type) {
if (suppression) {
supprimerObstacle();
}
var numero = new Array();
if (type == 1) {
if (id == 0 && idTunnel == 0) {
return;
}
var newNumber = nextNumber;
} else if (type == 2) {
var newNumber = nextNumber2;
} else if (type == 3) {
var newNumber = nextNumber3;
}
if (type == 1) {
for (var i = 1; i < nextNumber && newNumber != i - 1; i++) {
if (listeNumero[i] == "") {
newNumber = i;
}
}
} else if (type == 2) {
for (var i = 1; i < nextNumber2 && newNumber != i - 1; i++) {
if (listeNumero2[i] == "") {
newNumber = i;
}
}
} else if (type == 3) {
for (var i = 1; i < nextNumber3 && newNumber != i - 1; i++) {
if (listeNumero3[i] == "") {
newNumber = i;
}
}
}
decalX = LARGEUR_NUMERO / 2;
decalY = HAUTEUR_NUMERO / 2;
document.body.style.cursor = "move";
numero[0] = newNumber;
//if(canvas_x==null || canvas_x<0){
numero[1] = MARGE; //X
numero[2] = MARGE; //Y
//}
//numero[1]=canvas_x;//X
//numero[2]=canvas_y;//Y
if (type == 1) {
listeNumero[newNumber] = numero;
selNumeroId = newNumber;
if (newNumber == nextNumber) {
nextNumber++;
}
} else if (type == 2) {
listeNumero2[newNumber] = numero;
selNumeroId2 = newNumber;
if (newNumber == nextNumber2) {
nextNumber2++;
}
} else if (type == 3) {
listeNumero3[newNumber] = numero;
selNumeroId3 = newNumber;
if (newNumber == nextNumber3) {
nextNumber3++;
}
}
doMove();
genererParcours();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////SUPPRESSION DES OBSTACLES//////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function supprimerObstacle() {
suppression = !suppression;
if (suppression) {
document.body.style.cursor = "no-drop";
} else {
document.body.style.cursor = "default";
}
}
+340
View File
@@ -0,0 +1,340 @@
function changeColor(e, couleur) {
if (!color) {
document.getElementById(couleur).style.width = "256px";
document.getElementById(couleur).style.backgroundImage =
"url('palette.jpg')";
} else {
myFunction(e, couleur);
changeCouleurObstacle(couleur);
document.getElementById(couleur).style.width = "20px";
document.getElementById(couleur).style.backgroundImage = "";
}
color = !color;
}
function colorOut(couleur) {
document.getElementById(couleur).style.width = "20px";
document.getElementById(couleur).style.backgroundImage = "";
color = false;
}
var DECALX0 = 170;
var DECALY0 = 65;
var DECALX1 = 259;
var DECALY1 = 65;
var DECALX2 = 348;
var DECALY2 = 65;
var DECALX3 = 437;
var DECALY3 = 65;
var TAILLE_X = 256; // couleurs
var TAILLE_Y = 15; // luminosité
var rouge = 0;
var vert = TAILLE_X / 3;
var jaune = TAILLE_X / 6;
var bleu = TAILLE_X / 3 + TAILLE_X / 3;
var cyan = TAILLE_X / 6 + TAILLE_X / 3;
var majenta = TAILLE_X - TAILLE_X / 6;
var rouge2 = TAILLE_X;
var MaxColor = 255;
var r = 0;
var v = 0;
var b = 0;
function myFunction(e, couleur) {
if (couleur == "Couleur1") {
x = e.clientX - DECALX1;
y = e.clientY - DECALY1;
} else if (couleur == "Couleur2") {
x = e.clientX - DECALX2;
y = e.clientY - DECALY2;
} else if (couleur == "Couleur3") {
x = e.clientX - DECALX3;
y = e.clientY - DECALY3;
} else if (couleur == "Couleur0") {
x = e.clientX - DECALX0;
y = e.clientY - DECALY0;
}
r = 0;
v = 0;
b = 0;
if (x < jaune) {
r = MaxColor;
v = (x / jaune) * MaxColor;
b = 0;
} else if (x > jaune && x < vert) {
r = MaxColor - ((x - jaune) / jaune) * MaxColor;
v = MaxColor;
b = 0;
} else if (x > vert && x < cyan) {
r = 0;
b = ((x - jaune * 2) / jaune) * MaxColor;
v = MaxColor;
} else if (x > cyan && x < bleu) {
r = 0;
v = MaxColor - ((x - jaune * 3) / jaune) * MaxColor;
b = MaxColor;
} else if (x > bleu && x < majenta) {
r = ((x - jaune * 4) / jaune) * MaxColor;
v = 0;
b = MaxColor;
} else if (x > majenta && x < rouge2) {
r = MaxColor;
v = 0;
b = MaxColor - ((x - jaune * 5) / jaune) * MaxColor;
}
r = Math.round(r, 0);
v = Math.round(v, 0);
b = Math.round(b, 0);
r = r + 70;
v = v + 70;
b = b + 70;
if (r > MaxColor) {
r = MaxColor;
}
if (v > MaxColor) {
v = MaxColor;
}
if (b > MaxColor) {
b = MaxColor;
}
if (r > MaxColor) {
r = MaxColor;
}
if (v > MaxColor) {
v = MaxColor;
}
if (b > MaxColor) {
b = MaxColor;
}
document.getElementById(couleur).style.backgroundColor =
"rgba(" + r + ", " + v + ", " + b + ", 1)";
}
function changeCouleurObstacle(couleur) {
var r2 = r - 32;
var v2 = v - 32;
var b2 = b - 32;
if (r2 < 0) {
r2 = 0;
}
if (v2 < 0) {
v2 = 0;
}
if (b2 < 0) {
b2 = 0;
}
//var colorb= color
color = "#" + toHexa(r) + "" + toHexa(v) + "" + toHexa(b);
colorb = "#" + toHexa(r2) + "" + toHexa(v2) + "" + toHexa(b2);
if (couleur == "Couleur1") {
COLOR_1 = color;
COLOR_1b = colorb;
} else if (couleur == "Couleur2") {
COLOR_2 = color;
COLOR_2b = colorb;
} else if (couleur == "Couleur3") {
COLOR_3 = color;
} else if (couleur == "Couleur0") {
//fond
r = r + 140;
v = v + 140;
b = b + 140;
if (r > MaxColor) {
r = MaxColor;
}
if (v > MaxColor) {
v = MaxColor;
}
if (b > MaxColor) {
b = MaxColor;
}
color = "#" + toHexa(r) + "" + toHexa(v) + "" + toHexa(b);
colorb = "#" + toHexa(r2) + "" + toHexa(v2) + "" + toHexa(b2);
COLOR_TERRAIN = color;
COLOR_TEXT_UNDER =
"rgba(" +
toDec("r") +
", " +
toDec("v") +
", " +
toDec("b") +
", 0.7)"; // grilles
}
genererParcours();
}
function toHexa(initial) {
var regDec = /^\d+$/;
var converti = (converti = parseInt(initial, 10)
.toString(16)
.toUpperCase());
if (converti.length < 2) {
converti = "0" + converti;
}
return converti;
}
function toDec(initial) {
var regHexa = /^[a-f\d]+$/i;
var converti = parseInt(initial, 16);
return converti;
}
function setColorPredef(id) {
if (id == 1) {
//standard
COLOR_1 = "#22AAFF"; // principale
COLOR_1b = "#028ADF"; // principale sombre
COLOR_2 = "#CC3300"; // zones
COLOR_2b = "#AC1300"; // zones sombre
COLOR_3 = "#EEEEEE"; // couleur barre 2
COLOR_TEXT_UNDER = "rgba(211, 228, 240, 0.7)"; // grilles
COLOR_TERRAIN = "#d3e4f0"; // terrain CCFFCC
} else if (id == 2) {
//noir & blanc
COLOR_1 = "#555555"; // principale
COLOR_1b = "#353535"; // principale sombre
COLOR_2 = "#aaaaaa"; // zones
COLOR_2b = "#8a8a8a"; // zones sombre
COLOR_3 = "#ffffff"; // couleur barre 2
COLOR_TEXT_UNDER =
"rgba(" +
toDec("ee") +
", " +
toDec("ee") +
", " +
toDec("ee") +
", 0.7)"; // grilles
COLOR_TERRAIN = "#eeeeee"; // terrain CCFFCC
} else if (id == 3) {
//noir & rouge
COLOR_1 = "#555555"; // principale
COLOR_1b = "#353535"; // principale sombre
COLOR_2 = "#CC3300"; // zones
COLOR_2b = "#AC1300"; // zones sombre
COLOR_3 = "#ffffff"; // couleur barre 2
COLOR_TEXT_UNDER = "rgba(211, 228, 240, 0.7)"; // grilles
COLOR_TERRAIN = "#d3e4f0"; // terrain CCFFCC
} else if (id == 4) {
//eco color
COLOR_1 = "#99DDFF"; // principale
COLOR_1b = "#79BDDF"; // principale sombre
COLOR_2 = "#ff6666"; // zones
COLOR_2b = "#DF4646"; // zones sombre
COLOR_3 = "#EEEEEE"; // couleur barre 2
COLOR_TEXT_UNDER = "rgba(255, 255, 255, 0.7)"; // grilles
COLOR_TERRAIN = "#ffffff"; // terrain CCFFCC
} else if (id == 5) {
//eco noir & blanc
COLOR_1 = "#dddddd"; // principale
COLOR_1b = "#bdbdbd"; // principale sombre
COLOR_2 = "#bbbbbb"; // zones
COLOR_2b = "#9b9b9b"; // zones sombre
COLOR_3 = "#ffffff"; // couleur barre 2
COLOR_TEXT_UNDER =
"rgba(" +
toDec("ff") +
", " +
toDec("ff") +
", " +
toDec("ff") +
", 0.7)"; // grilles
COLOR_TERRAIN = "#ffffff"; // terrain CCFFCC
} else if (id == 6) {
//standard
COLOR_1 = "#dddddd"; // principale
COLOR_1b = "#bdbdbd"; // principale sombre
COLOR_2 = "#CC3300"; // zones
COLOR_2b = "#AC1300"; // zones sombre
COLOR_3 = "#EEEEEE"; // couleur barre 2
COLOR_TEXT_UNDER = "rgba(211, 228, 240, 0.7)"; // grilles
COLOR_TERRAIN = "#CCFFCC"; // terrain CCFFCC
}
genererParcours();
}
function setBackgroundColor(id) {
if (id == 1) {
COLOR_TEXT_UNDER = "rgba(255, 255,255, 0.7)";
COLOR_TERRAIN = "#ffffff";
COLOR_GRILLE = "#cccccc"; // grilles
} else if (id == 2) {
COLOR_TEXT_UNDER = "rgba(211, 228, 240, 0.7)";
COLOR_TERRAIN = "rgba(211, 228, 240, 1)";
COLOR_GRILLE = "#bdcdd8"; // grilles
} else if (id == 3) {
COLOR_TEXT_UNDER = "rgba(211, 228, 240, 0.7)";
COLOR_TERRAIN = "rgba(204, 255, 204, 1)";
COLOR_GRILLE = "#b2e0b2"; // grilles
}
genererParcours();
}
function setDriverColor(id) {
if (id == 1) {
COLOR_VETEMENTS = "#bbbbbb";
} else if (id == 2) {
COLOR_VETEMENTS = "#CC3300";
} else if (id == 3) {
COLOR_VETEMENTS = "#22AAFF";
}
genererParcours();
}
function setObstacleColor(id) {
if (id == 1) {
//eco noir & blanc
COLOR_1 = "#dddddd"; // principale
COLOR_1b = "#bdbdbd"; // principale sombre
COLOR_2 = "#bbbbbb"; // zones
COLOR_2b = "#9b9b9b"; // zones sombre
COLOR_3 = "#ffffff"; // couleur barre 2
} else if (id == 2) {
//standard
COLOR_1 = "#22AAFF"; // principale
COLOR_1b = "#028ADF"; // principale sombre
COLOR_2 = "#CC3300"; // zones
COLOR_2b = "#AC1300"; // zones sombre
COLOR_3 = "#EEEEEE"; // couleur barre 2
} else if (id == 3) {
//noir & rouge
COLOR_1 = "#555555"; // principale
COLOR_1b = "#353535"; // principale sombre
COLOR_2 = "#CC3300"; // zones
COLOR_2b = "#AC1300"; // zones sombre
COLOR_3 = "#ffffff"; // couleur barre 2
} else if (id == 4) {
//blanc rouge
COLOR_1 = "#dddddd"; // principale
COLOR_1b = "#bdbdbd"; // principale sombre
COLOR_2 = "#CC3300"; // zones
COLOR_2b = "#AC1300"; // zones sombre
COLOR_3 = "#EEEEEE"; // couleur barre 2
} else if (id == 5) {
//noir & rouge
COLOR_1 = "#555555"; // principale
COLOR_1b = "#353535"; // principale sombre
COLOR_2 = "#e07ecd "; // zones
COLOR_2b = "#ae629f"; // zones sombre
COLOR_3 = "#ffffff"; // couleur barre 2
}
genererParcours();
}
/*
var COLOR_1="#22AAFF";// principale
var COLOR_1b="#0088DD";// principale sombre
var COLOR_2="#CC3300";// zones
var COLOR_2b="#AA1100";// zones sombre
var COLOR_3="#EEEEEE";// couleur barre 2
*/
+746
View File
@@ -0,0 +1,746 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////LISTENER D EVENEMENTS/////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doTouchStart(event) {
isTactil = true;
setMargeSelect();
//document.getElementById('outils').style.overflow="scroll";
//document.getElementById('trajMaitre').style.overflow="scroll";
window.removeEventListener("mousemove", doMouseMove, false);
window.removeEventListener("mouseup", doMouseUp, false);
canvas.removeEventListener("mousedown", doMouseDown, false);
canvas.addEventListener("touchmove", doTouchMove, false);
canvas.addEventListener("touchend", doTouchEnd, false);
canvas.addEventListener("touchleave", doTouchEnd, false);
canvas.addEventListener("touchcancel", doTouchEnd, false);
//event.preventDefault();
doTouchMove(event);
doMouseDown(event);
}
function doTouchEnd(event) {
//event.preventDefault();
doMouseUp(event);
doTouchMove(event);
}
function doTouchMove(event) {
var touches = event.changedTouches;
oldx = canvas_x;
canvas_x = touches[0].pageX - DECAL_X_INTERFACE;
canvas_x = canvas_x / scale;
diffx = oldx - canvas_x;
if (canvas_x > canvasSizeX - MARGE) {
canvas_x = canvasSizeX - MARGE;
} else if (canvas_x < MARGE) {
canvas_x = MARGE;
}
oldy = canvas_y;
canvas_y = touches[0].pageY - DECAL_Y_INTERFACE;
canvas_y = canvas_y / scale;
diffy = oldy - canvas_y;
if (canvas_y > canvasSizeY - MARGE * 2) {
canvas_y = canvasSizeY - MARGE * 2;
} else if (canvas_y < MARGE) {
canvas_y = MARGE;
}
doMove();
if (isOverObstacle()) {
log("over obstacle");
event.preventDefault();
} else {
log("not over obstacle");
}
}
function isOverObstacle() {
if (
overObject == -1 &&
overTunnelId == -1 &&
overPointTunnel == -1 &&
overTunnelComplet == -1 &&
overModifTrajId == -1 &&
overModifTrajDepArr == -1 &&
overNumeroId == -1 &&
overNumeroId2 == -1 &&
overNumeroId3 == -1 &&
overObject == -1
) {
return false;
}
return true;
}
function doMouseDown(event) {
window.addEventListener("mouseup", doMouseUp, false);
canvas.removeEventListener("mousedown", doMouseDown, false);
if (suppression == true) {
if (overNumeroId != -1) {
listeNumero[overNumeroId] = "";
// fix path when last number is deleted
if (overNumeroId+1==nextNumber) {
nextNumber--;
listeNumero.pop();
}
} else if (overNumeroId2 != -1) {
listeNumero2[overNumeroId2] = "";
} else if (overNumeroId3 != -1) {
listeNumero3[overNumeroId3] = "";
} else if (overTunnelId != -1) {
tbTunnels[overTunnelId] = "";
} else if (overTunnelComplet != -1) {
tbTunnels[overTunnelComplet] = "";
} else if (overObject != -1) {
tbObst[overObject] = "";
}
} else if (overNumeroId != -1) {
selNumeroId = overNumeroId;
} else if (overNumeroId2 != -1) {
selNumeroId2 = overNumeroId2;
} else if (overNumeroId3 != -1) {
selNumeroId3 = overNumeroId3;
} else if (overModifTrajId != -1) {
modifTrajId = overModifTrajId;
modifTrajDepArr = overModifTrajDepArr;
} else if (overTunnelId != -1) {
selTunnel = overTunnelId;
selPointTunnel = overPointTunnel;
} else if (overTunnelComplet != -1) {
selTunnelComplet = overTunnelComplet;
} else if (overObject != -1) {
selObst = overObject;
setCanvasX(selObst, canvas_x - decalX);
setCanvasY(selObst, canvas_y - decalY);
genererParcours();
}
}
function doMouseUp(event) {
//window.removeEventListener("mousemove", doMouseMove, false);
window.removeEventListener("mouseup", doMouseUp, false);
canvas.addEventListener("mousedown", doMouseDown, false);
selObst = -1;
selTunnel = -1;
selPointTunnel = -1;
selTunnelComplet = -1;
rotate = false;
moveTunnelComplet = -1;
selNumeroId = -1;
selNumeroId2 = -1;
selNumeroId3 = -1;
modifTrajId = -1;
modifTrajDepArr = -1;
genererParcours();
}
function doMouseMove(event) {
oldx = canvas_x;
canvas_x = event.pageX - DECAL_X_INTERFACE;
canvas_x = canvas_x / scale;
diffx = oldx - canvas_x;
if (canvas_x > canvasSizeX - MARGE) {
canvas_x = canvasSizeX - MARGE;
} else if (canvas_x < MARGE) {
canvas_x = MARGE;
}
oldy = canvas_y;
canvas_y = event.pageY - DECAL_Y_INTERFACE;
canvas_y = canvas_y / scale;
diffy = oldy - canvas_y;
if (canvas_y > canvasSizeY - MARGE * 2) {
canvas_y = canvasSizeY - MARGE * 2;
} else if (canvas_y < MARGE) {
canvas_y = MARGE;
}
doMove();
}
///////////////////////////////////////////////////////////////////////MOUVEMENT///////////////////////////////////////////////////////////
function rchObstacleProche(xProche, yProche, numero) {
var idPlusProche = 0;
var xPlusProche = 1000;
var yPlusProche = 1000;
var distanceHypoPlusProche = 1000;
var sens = 1;
var type = "classique";
for (var i = 0; i < id; i++) {
var x = getCanvasX(i);
var y = getCanvasY(i);
var nom = getSens(i);
var largx = getXCliquable(i);
var hauty = getYCliquable(i);
var angle = getAngle(i);
var type = "classique";
var modifXDep = getModXTrajEntree(i);
var modifYDep = getModYTrajEntree(i);
var modifXArr = getModXTrajSortie(i);
var modifYArr = getModYTrajSortie(i);
var angleSens2 = getAngleTrajSortie(i);
var longTraj = getDistTrajCentre(i);
var distanceSup = 3;
var departX =
x +
modifXDep / 2 +
Math.cos(((angle + angleSens2) / 180) * Math.PI) *
(longTraj / 2 + distanceSup);
var departY =
y +
modifYDep / 2 +
Math.sin(((angle + angleSens2) / 180) * Math.PI) *
(longTraj / 2 + distanceSup);
var xDist = Math.abs(departX - xProche);
var yDist = Math.abs(departY - yProche);
var distanceHypo = Math.sqrt(Math.pow(xDist, 2) + Math.pow(yDist, 2));
if (distanceHypo < distanceHypoPlusProche) {
idPlusProche = i;
xPlusProche = xDist;
yPlusProche = yDist;
distanceHypoPlusProche = distanceHypo;
sens = 1;
xpp = departX;
ypp = departY;
type = "classique";
}
var arriveX =
x +
modifXArr / 2 +
Math.cos(((angle + angleSens2) / 180) * Math.PI) *
(-longTraj / 2 - distanceSup);
var arriveY =
y +
modifYArr / 2 +
Math.sin(((angle + angleSens2) / 180) * Math.PI) *
(-longTraj / 2 - distanceSup);
var xDistArr = Math.abs(arriveX - xProche);
var yDistArr = Math.abs(arriveY - yProche);
var distanceHypoFin = Math.sqrt(
Math.pow(xDistArr, 2) + Math.pow(yDistArr, 2)
);
if (distanceHypoFin < distanceHypoPlusProche) {
idPlusProche = i;
xPlusProche = xDistArr;
yPlusProche = yDistArr;
distanceHypoPlusProche = distanceHypoFin;
sens = 0;
xpp = arriveX;
ypp = arriveY;
type = "classique";
}
}
for (var j = 0; j < idTunnel; j++) {
var xTun = tbTunnels[j][1];
var yTun = tbTunnels[j][2];
var xTunFin = tbTunnels[j][(nbArticulationTunnel - 1) * 2 + 1];
var yTunFin = tbTunnels[j][(nbArticulationTunnel - 1) * 2 + 2];
//var x2Tun=tbTunnels[j][3];// pour le premier angle
//var y2Tun=tbTunnels[j][4];// pour le premier angle
var largXTun = 0;
var largYTun = 0;
var angleTun = 90;
var modifXDepTun = 0;
var modifYDepTun = 0;
var modifXArrTun = 0;
var modifYArrTun = 0;
//var distXTun = xTun - x2Tun;
//var distYTun = yTun - y2Tun;
//var modifAngleArrTun = Math.atan2(distYTun,distXTun)/Math.PI*180-90;
var longTrajTun = 0;
var xDist = Math.abs(xProche - xTun);
var yDist = Math.abs(yProche - yTun);
var distanceHypo = Math.sqrt(Math.pow(xDist, 2) + Math.pow(yDist, 2));
if (distanceHypo < distanceHypoPlusProche) {
idPlusProche = j;
xPlusProche = xDist;
yPlusProche = yDist;
distanceHypoPlusProche = distanceHypo;
sens = 1;
xpp = xTun;
ypp = yTun;
type = "tunnel";
}
var xDistFin = Math.abs(xProche - xTunFin);
var yDistFin = Math.abs(yProche - yTunFin);
var distanceHypoFin = Math.sqrt(
Math.pow(xDistFin, 2) + Math.pow(yDistFin, 2)
);
if (distanceHypoFin < distanceHypoPlusProche) {
idPlusProche = j;
xPlusProche = xDistFin;
yPlusProche = yDistFin;
distanceHypoPlusProche = distanceHypoFin;
sens = 0;
xpp = xTunFin;
ypp = yTunFin;
type = "tunnel";
}
}
xp = xProche;
yp = yProche;
var ordreObstacle = new Array();
ordreObstacle[0] = idPlusProche;
ordreObstacle[1] = type; //type
var xNumProche;
var yNumProche;
var angleProche;
var modXProche;
var modYProche;
if (ordreObst[numero] != null && ordreObst[numero][0] == idPlusProche) {
if (type == "tunnel") {
ordreObstacle[7] = 90;
ordreObstacle[8] = 50;
ordreObstacle[9] = 90;
ordreObstacle[10] = 50;
xNumProche = 0;
yNumProche = 0;
modXProche = 0;
modYProche = 0;
angleProche = 0;
} else if (ordreObst[numero][1] == "tunnel") {
xNumProche = getCanvasX(idPlusProche);
yNumProche = getCanvasY(idPlusProche);
ordreObstacle[7] = getAngleTrajSortie(idPlusProche);
ordreObstacle[8] = getLongTraj(idPlusProche);
ordreObstacle[9] = getAngleTrajSortie(idPlusProche);
ordreObstacle[10] = getLongTraj(idPlusProche);
modXProche = getModXTrajSortie(idPlusProche);
modYProche = getModYTrajSortie(idPlusProche);
angleProche = getAngle(idPlusProche);
} else {
if (ordreObst[numero][2] != sens) {
xNumProche = getCanvasX(idPlusProche);
yNumProche = getCanvasY(idPlusProche);
ordreObstacle[7] = getAngleTrajSortie(idPlusProche);
ordreObstacle[8] = getLongTraj(idPlusProche);
ordreObstacle[9] = getAngleTrajSortie(idPlusProche);
ordreObstacle[10] = getLongTraj(idPlusProche);
modXProche = getModXTrajSortie(idPlusProche);
modYProche = getModYTrajSortie(idPlusProche);
angleProche = getAngle(idPlusProche);
} else {
xNumProche = getCanvasX(idPlusProche);
yNumProche = getCanvasY(idPlusProche);
ordreObstacle[7] = ordreObst[numero][7];
ordreObstacle[8] = ordreObst[numero][8];
ordreObstacle[9] = ordreObst[numero][9];
ordreObstacle[10] = ordreObst[numero][10];
modXProche = getModXTrajSortie(idPlusProche);
modYProche = getModYTrajSortie(idPlusProche);
angleProche = getAngle(idPlusProche);
//log(ordreObstacle[7]+"_"+ordreObstacle[8]+"_"+ordreObstacle[9]+"_"+ordreObstacle[10]);
}
}
} else {
if (type == "tunnel") {
ordreObstacle[7] = 90;
ordreObstacle[8] = 50;
ordreObstacle[9] = 90;
ordreObstacle[10] = 50;
xNumProche = 0;
yNumProche = 0;
modXProche = 0;
modYProche = 0;
angleProche = 0;
} else {
ordreObstacle[7] = getAngleTrajSortie(idPlusProche);
ordreObstacle[8] = getLongTraj(idPlusProche);
ordreObstacle[9] = getAngleTrajSortie(idPlusProche);
ordreObstacle[10] = getLongTraj(idPlusProche);
xNumProche = getCanvasX(idPlusProche);
yNumProche = getCanvasY(idPlusProche);
modXProche = getModXTrajSortie(idPlusProche);
modYProche = getModYTrajSortie(idPlusProche);
angleProche = getAngle(idPlusProche);
}
}
ordreObstacle[2] = sens; //sens
var xComp = listeNumero[numero][1] - xNumProche - modXProche / 2;
var yComp = listeNumero[numero][2] - yNumProche - modYProche / 2;
// calcul de l'angle par rapport au centre.
var dist = Math.sqrt(Math.pow(xComp, 2) + Math.pow(yComp, 2));
var angleNumero = (Math.atan2(yComp, xComp) / Math.PI) * 180 - angleProche;
listeNumero[numero][3] = angleNumero;
listeNumero[numero][4] = dist;
// calcul de l'angle avec le centre de l'obstacle qui lui est lié
ordreObst[numero] = ordreObstacle;
}
var xp = 0;
var yp = 0;
var xpp = 0;
var ypp = 0;
var xTst = 0;
var yTst = 0;
var xTst2 = 0;
var yTst2 = 0;
var xTst3 = 0;
var yTst3 = 0;
/*
function afficherTest(){
context.fillStyle="#ff0000";
rect(xTst,yTst,1,1);
//jaune
context.fillStyle="#ffFF00";
rect(xTst2,yTst2,1,1);
context.fillStyle="#00FF00";
rect(xTst3,yTst3,1,1);
}*/
function recupereListeNumero(id, type) {
// récupère la liste des numéros qui sont liés à un obstacle.
for (var i = 1; i < nextNumber; i++) {
if (ordreObst[i][0] == id && ordreObst[i][1] == type) {
listeNumero[i][1] = listeNumero[i][1] - diffx;
listeNumero[i][2] = listeNumero[i][2] - diffy;
}
}
}
function recupereListeNumeroAngle(id, type, angle) {
// déplace le numéro lors d'une rotation
// récupère la liste des numéros qui sont liés à un obstacle.
for (var i = 1; i < nextNumber; i++) {
if (ordreObst[i][0] == id && ordreObst[i][1] == type) {
if (type == "tunnel") {
} else {
// calcul de l'angle par rapport au centre.
var distance = listeNumero[i][4];
var newAngle = getAngle(id) + listeNumero[i][3];
var newX =
getCanvasX(id) +
getModXTrajSortie(id) / 2 +
Math.cos((newAngle / 180) * Math.PI) * distance;
var newY =
getCanvasY(id) +
getModYTrajSortie(id) / 2 +
Math.sin((newAngle / 180) * Math.PI) * distance;
listeNumero[i][1] = newX;
listeNumero[i][2] = newY;
}
}
}
}
function doMove() {
movingJump = false;
if (
overObject == -1 &&
selTunnel == -1 &&
selTunnelComplet == -1 &&
!suppression &&
!color &&
overModifTrajId == -1
) {
document.body.style.cursor = "default";
} else if (color) {
document.body.style.cursor = "crosshair";
}
if (
selNumeroId == -1 &&
selObst == -1 &&
selTunnel == -1 &&
selTunnelComplet == -1 &&
modifTrajId == -1 &&
selNumeroId2 == -1 &&
selNumeroId3 == -1
) {
overObject = -1;
overTunnelId = -1;
overPointTunnel = -1;
overTunnelComplet = -1;
overModifTrajId = -1;
overModifTrajDepArr = -1;
overNumero(canvas_x, canvas_y);
overNumero2(canvas_x, canvas_y);
overNumero3(canvas_x, canvas_y);
overObstacle(canvas_x, canvas_y);
overRotate(canvas_x, canvas_y);
overTunnel(canvas_x, canvas_y);
if (document.getElementById("ModifierTrajectoires").checked) {
overModifTraj(canvas_x, canvas_y);
}
genererParcours();
} else {
movingJump = true;
if (modifTrajId != -1) {
var idObst = ordreObst[modifTrajId][0];
} else if (selNumeroId != -1) {
listeNumero[selNumeroId][1] = canvas_x - decalX;
listeNumero[selNumeroId][2] = canvas_y - decalY;
if (listeNumero[selNumeroId][1] - LARGEUR_NUMERO / 2 < MARGE) {
listeNumero[selNumeroId][1] = MARGE + LARGEUR_NUMERO / 2;
} else if (
listeNumero[selNumeroId][1] + LARGEUR_NUMERO / 2 >
canvasSizeX - MARGE
) {
listeNumero[selNumeroId][1] =
canvasSizeX - MARGE - LARGEUR_NUMERO / 2;
}
if (listeNumero[selNumeroId][2] - HAUTEUR_NUMERO / 2 < MARGE) {
listeNumero[selNumeroId][2] = MARGE + HAUTEUR_NUMERO / 2;
} else if (
listeNumero[selNumeroId][2] + HAUTEUR_NUMERO / 2 >
canvasSizeY - MARGE * 2
) {
listeNumero[selNumeroId][2] =
canvasSizeY - MARGE * 2 - HAUTEUR_NUMERO / 2;
}
rchObstacleProche(
listeNumero[selNumeroId][1],
listeNumero[selNumeroId][2],
selNumeroId
);
// calcul de l'angle
} else if (selNumeroId2 != -1) {
listeNumero2[selNumeroId2][1] = canvas_x - decalX;
listeNumero2[selNumeroId2][2] = canvas_y - decalY;
if (listeNumero2[selNumeroId2][1] - LARGEUR_NUMERO / 2 < MARGE) {
listeNumero2[selNumeroId2][1] = MARGE + LARGEUR_NUMERO / 2;
} else if (
listeNumero2[selNumeroId2][1] + LARGEUR_NUMERO / 2 >
canvasSizeX - MARGE
) {
listeNumero2[selNumeroId2][1] =
canvasSizeX - MARGE - LARGEUR_NUMERO / 2;
}
if (listeNumero2[selNumeroId2][2] - HAUTEUR_NUMERO / 2 < MARGE) {
listeNumero2[selNumeroId2][2] = MARGE + HAUTEUR_NUMERO / 2;
} else if (
listeNumero2[selNumeroId2][2] + HAUTEUR_NUMERO / 2 >
canvasSizeY - MARGE * 2
) {
listeNumero2[selNumeroId2][2] =
canvasSizeY - MARGE * 2 - HAUTEUR_NUMERO / 2;
}
} else if (selNumeroId3 != -1) {
listeNumero3[selNumeroId3][1] = canvas_x - decalX;
listeNumero3[selNumeroId3][2] = canvas_y - decalY;
if (listeNumero3[selNumeroId3][1] - LARGEUR_NUMERO / 2 < MARGE) {
listeNumero3[selNumeroId3][1] = MARGE + LARGEUR_NUMERO / 2;
} else if (
listeNumero3[selNumeroId3][1] + LARGEUR_NUMERO / 2 >
canvasSizeX - MARGE
) {
listeNumero3[selNumeroId3][1] =
canvasSizeX - MARGE - LARGEUR_NUMERO / 2;
}
if (listeNumero3[selNumeroId3][2] - HAUTEUR_NUMERO / 2 < MARGE) {
listeNumero3[selNumeroId3][2] = MARGE + HAUTEUR_NUMERO / 2;
} else if (
listeNumero3[selNumeroId3][2] + HAUTEUR_NUMERO / 2 >
canvasSizeY - MARGE * 2
) {
listeNumero3[selNumeroId3][2] =
canvasSizeY - MARGE * 2 - HAUTEUR_NUMERO / 2;
}
} else if (selTunnelComplet != -1) {
//déplace le tunnel complet
var decallageReelX =
tbTunnels[selTunnelComplet][1] - canvas_x + decalX;
var decallageReelY =
tbTunnels[selTunnelComplet][2] - canvas_y + decalY;
for (var art = 0; art < nbArticulationTunnel; art++) {
tbTunnels[selTunnelComplet][art * 2 + 1] =
tbTunnels[selTunnelComplet][art * 2 + 1] - decallageReelX;
tbTunnels[selTunnelComplet][art * 2 + 2] =
tbTunnels[selTunnelComplet][art * 2 + 2] - decallageReelY;
}
recupereListeNumero(selTunnelComplet, "tunnel");
} else if (selTunnel != -1) {
// déplace une articulation
moveTunnel(selTunnel, selPointTunnel, canvas_x, canvas_y, -1);
recupereListeNumero(selTunnel, "tunnel");
} else if (moveTunnelComplet != -1) {
for (var art = 0; art < nbArticulationTunnel; art++) {
if (art == 1 || art == 3 || art == 5 || art == 6) {
tbObst[selObst][art] = tbObst[selObst][art] + moveTunnelX;
} else {
tbObst[selObst][art] = tbObst[selObst][art] + moveTunnelY;
}
}
recupereListeNumero(moveTunnelComplet, "tunnel");
} else if (!rotate) {
setCanvasX(selObst, canvas_x - decalX);
setCanvasY(selObst, canvas_y - decalY);
recupereListeNumero(selObst, "classique");
} else {
// calcul de l'angle par rapport au centre.
var distX =
canvas_x - getCanvasX(selObst) - getXCliquable(selObst) / 2;
var distY =
canvas_y - getCanvasY(selObst) - getYCliquable(selObst) / 2;
var angle = (Math.atan2(distY, distX) / Math.PI) * 180;
if (rotateCote == "gauche") {
setAngle(selObst, angle);
} else {
if (angle > 0) {
setAngle(selObst, angle - 180);
} else {
setAngle(selObst, angle + 180);
}
}
recupereListeNumeroAngle(selObst, "classique", getAngle(selObst));
}
genererParcours();
}
}
function moveTunnel(idTunnel, idPointTunnel, X, Y, idPointTunnelPrecedent) {
var newX;
var newY;
var oldX = tbTunnels[idTunnel][idPointTunnel * 2 + 1];
var oldY = tbTunnels[idTunnel][idPointTunnel * 2 + 2];
var type = tbTunnels[idTunnel][nbArticulationTunnel * 2 + 3];
var dist;
var angle;
newX = X;
newY = Y;
if (idPointTunnel - 1 >= 0) {
var xPre = tbTunnels[idTunnel][(idPointTunnel - 1) * 2 + 1];
var yPre = tbTunnels[idTunnel][(idPointTunnel - 1) * 2 + 2];
var anglePrecedent =
180 + (Math.atan2(yPre - newY, xPre - newX) / Math.PI) * 180;
}
if (idPointTunnel + 1 < nbArticulationTunnel) {
var xSui = tbTunnels[idTunnel][(idPointTunnel + 1) * 2 + 1];
var ySui = tbTunnels[idTunnel][(idPointTunnel + 1) * 2 + 2];
var angleSuivant =
180 + (Math.atan2(ySui - newY, xSui - newX) / Math.PI) * 180;
}
if (idPointTunnel - 1 >= 0 && idPointTunnel + 1 < nbArticulationTunnel) {
angleSurplus = 0;
if (
!(
Math.abs(anglePrecedent - angleSuivant) > ANGLE_MIN &&
Math.abs(anglePrecedent - angleSuivant) < 360 - ANGLE_MIN
)
) {
angleSurplus = diffAngle(angleSuivant, anglePrecedent);
}
}
// si aucun point n'a été bougé précédement on bouge l point actuel
if (idPointTunnelPrecedent == -1) {
tbTunnels[idTunnel][idPointTunnel * 2 + 1] = newX;
tbTunnels[idTunnel][idPointTunnel * 2 + 2] = newY;
}
// Effectuer le déplacement des point dans les cotés
//if(idPointTunnelPrecedent!=-1){
// point suivant
if (idPointTunnel - 1 >= 0 && idPointTunnel - 1 != idPointTunnelPrecedent) {
var distPre = Math.sqrt(
Math.pow(xPre - newX, 2) + Math.pow(yPre - newY, 2)
);
var anglePreced =
(Math.atan2(yPre - newY, xPre - newX) / Math.PI) * 180;
anglePreced = anglePreced - angleSurplus;
//anglePreced=anglePreced-angleSurplus;
var newXPre = 0;
var newYPre = 0;
if (type == 3) {
var distMax = distMaxTunnel3;
var distMin = distMinTunnel3;
} else {
var distMax = distMaxTunnel;
var distMin = distMinTunnel;
}
if (distPre > distMax) {
newXPre = Math.cos((anglePreced / 180) * Math.PI) * distMax + X;
newYPre = Math.sin((anglePreced / 180) * Math.PI) * distMax + Y;
} else if (distPre < distMin) {
newXPre = Math.cos((anglePreced / 180) * Math.PI) * distMin + X;
newYPre = Math.sin((anglePreced / 180) * Math.PI) * distMin + Y;
} else {
// pas de transmission de mouvement si les écarts sont respectés.
newXPre = Math.cos((anglePreced / 180) * Math.PI) * distPre + X;
newYPre = Math.sin((anglePreced / 180) * Math.PI) * distPre + Y;
//return;
}
tbTunnels[idTunnel][(idPointTunnel - 1) * 2 + 1] = newXPre;
tbTunnels[idTunnel][(idPointTunnel - 1) * 2 + 2] = newYPre;
//moveTunnel(idTunnel,idPointTunnel-1, newX, newY, idPointTunnel)
}
// transmission du mouvement vers suivants
if (
idPointTunnel + 1 < nbArticulationTunnel &&
idPointTunnel + 1 != idPointTunnelPrecedent
) {
var distSui = Math.sqrt(
Math.pow(xSui - newX, 2) + Math.pow(ySui - newY, 2)
);
var angleSuiv = (Math.atan2(ySui - newY, xSui - newX) / Math.PI) * 180;
angleSuiv = angleSuiv + angleSurplus;
var newXSui = 0;
var newYSui = 0;
if (type == 3) {
var distMax = distMaxTunnel3;
var distMin = distMinTunnel3;
} else {
var distMax = distMaxTunnel;
var distMin = distMinTunnel;
}
if (distSui > distMax) {
newXSui = Math.cos((angleSuiv / 180) * Math.PI) * distMax + X;
newYSui = Math.sin((angleSuiv / 180) * Math.PI) * distMax + Y;
} else if (distSui < distMin) {
newXSui = Math.cos((angleSuiv / 180) * Math.PI) * distMin + X;
newYSui = Math.sin((angleSuiv / 180) * Math.PI) * distMin + Y;
} else {
newXSui = Math.cos((angleSuiv / 180) * Math.PI) * distSui + X;
newYSui = Math.sin((angleSuiv / 180) * Math.PI) * distSui + Y;
}
tbTunnels[idTunnel][(idPointTunnel + 1) * 2 + 1] = newXSui;
tbTunnels[idTunnel][(idPointTunnel + 1) * 2 + 2] = newYSui;
}
// on transmet le mouvement aux autres points
// transmission du mouvement vers précédents
if (idPointTunnel - 1 >= 0 && idPointTunnel - 1 != idPointTunnelPrecedent) {
moveTunnel(
idTunnel,
idPointTunnel - 1,
newXPre,
newYPre,
idPointTunnel
);
}
// transmission du mouvement vers suivants
if (
idPointTunnel + 1 < nbArticulationTunnel &&
idPointTunnel + 1 != idPointTunnelPrecedent
) {
moveTunnel(
idTunnel,
idPointTunnel + 1,
newXSui,
newYSui,
idPointTunnel
);
}
}
+166
View File
@@ -0,0 +1,166 @@
// GETTERS
function getId(idObstacle){
return tbObst[idObstacle][0];
}
function getCanvasX(idObstacle){
return tbObst[idObstacle][1];
}
function getCanvasY(idObstacle){
return tbObst[idObstacle][2];
}
function getSens(idObstacle){// aussi le nom et l'image
return tbObst[idObstacle][3];;
}
function getXCliquable(idObstacle){
return tbObst[idObstacle][4];
}
function getYCliquable(idObstacle){
return tbObst[idObstacle][5];
}
function getAngle(idObstacle){
return tbObst[idObstacle][6];
}
function getType(idObstacle){
return tbObst[idObstacle][7];
}
function getModXTrajEntree(idObstacle){
return tbObst[idObstacle][8];
}
function getModYTrajEntree(idObstacle){
return tbObst[idObstacle][9];
}
function getModXTrajSortie(idObstacle){
return tbObst[idObstacle][10];
}
function getModYTrajSortie(idObstacle){
return tbObst[idObstacle][11];
}
function getAngleTrajSortie(idObstacle){
return tbObst[idObstacle][12];
}
function getDistTrajCentre(idObstacle){
return tbObst[idObstacle][13];
}
function getLongTraj(idObstacle){
return tbObst[idObstacle][14];
}
// SETTERS
function setId(idObstacle,valeur){
tbObst[idObstacle][0] = valeur;
}
function setCanvasX(idObstacle,valeur){
tbObst[idObstacle][1] = valeur;
}
function setCanvasY(idObstacle,valeur){
tbObst[idObstacle][2] = valeur;
}
function setImg(idObstacle,valeur){
tbObst[idObstacle][3] = valeur;
}
function setXCliquable(idObstacle,valeur){
tbObst[idObstacle][4] = valeur;
}
function setYCliquable(idObstacle,valeur){
tbObst[idObstacle][5] = valeur;
}
function setAngle(idObstacle,valeur){
tbObst[idObstacle][6] = valeur;
}
function setType(idObstacle,valeur){
tbObst[idObstacle][7] = valeur;
}
function setModXTrajEntree(idObstacle,valeur){
tbObst[idObstacle][8] = valeur;
}
function setModYTrajEntree(idObstacle,valeur){
tbObst[idObstacle][9] = valeur;
}
function setModXTrajSortie(idObstacle,valeur){
tbObst[idObstacle][10] = valeur;
}
function setModYTrajSortie(idObstacle,valeur){
tbObst[idObstacle][11] = valeur;
}
function setAngleTrajSortie(idObstacle,valeur){
tbObst[idObstacle][12] = valeur;
}
function setDistTrajCentre(idObstacle,valeur){
tbObst[idObstacle][13] = valeur;
}
function setLongTraj(idObstacle,valeur){
tbObst[idObstacle][14] = valeur;
}
// TUNNELS
function getIdTunnel(idTunnel){
return tbTunnels[idTunnel][0];
}
function setIdTunnel(idTunnel,valeur){
tbTunnels[idTunnel][0] = valeur;
}
//NUMEROS
function getIdNumero(idNum, numListe){
switch(numListe){
case 1:
return listeNumero[idNum][0];
case 2:
return listeNumero2[idNum][0];
case 3:
return listeNumero3[idNum][0];
}
}
function getXNumero(idNum, numListe){
return listeNumero[idNum][1];
}
function getYNumero(idNum, numListe){
return listeNumero[idNum][2];
}
function setIdNumero(idNum,valeur, numListe){
switch(numListe){
case 1:
listeNumero[idNum][0]=valeur;
break;
case 2:
listeNumero2[idNum][0]=valeur;
break;
case 3:
listeNumero3[idNum][0]=valeur;
break;
}
}
function setXNumero(idNum,valeur, numListe){
switch(numListe){
case 1:
listeNumero[idNum][1]=valeur;
break;
case 2:
listeNumero2[idNum][1]=valeur;
break;
case 3:
listeNumero3[idNum][1]=valeur;
break;
}
}
function setYNumero(idNum,valeur, numListe){
switch(numListe){
case 1:
listeNumero[idNum][2]=valeur;
break;
case 2:
listeNumero2[idNum][2]=valeur;
break;
case 3:
listeNumero3[idNum][2]=valeur;
break;
}
}
+519
View File
@@ -0,0 +1,519 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////FONCTIONS//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var isOpenBarreOutil = true;
var isOpenBarreTitre = true;
function switchBarreOutil() {
if (isOpenBarreOutil) {
//fermeture
DECAL_X_INTERFACE = 15;
document.getElementById("barreOutilCache").style.left = "0px";
document.getElementById("contentCanvas").style.left = "15px";
document.getElementById("outils").style.visibility = "hidden";
document.getElementById("trajMaitre").style.visibility = "hidden";
} else {
//ouverture
DECAL_X_INTERFACE = 110;
document.getElementById("barreOutilCache").style.left = "95px";
document.getElementById("contentCanvas").style.left = "110px";
document.getElementById("outils").style.visibility = "visible";
document.getElementById("trajMaitre").style.visibility = "visible";
}
isOpenBarreOutil = !isOpenBarreOutil;
}
function switchBarreTitre() {
if (isOpenBarreTitre) {
//fermeture
DECAL_Y_INTERFACE = 15;
document.getElementById("barreOutilCache").style.top = "15px";
document.getElementById("outils").style.top = "15px";
document.getElementById("trajMaitre").style.top = "15px";
document.getElementById("barreTitreCache").style.top = "0px";
document.getElementById("contentCanvas").style.top = "15px";
document.getElementById("titre").style.visibility = "hidden";
document.getElementById("options").style.visibility = "hidden";
document.getElementById("logo").style.visibility = "hidden";
document.getElementById("medaille").style.visibility = "hidden";
document.getElementById("barreInfo").style.visibility = "hidden";
document.getElementById("titreLogo").style.visibility = "hidden";
} else {
//ouverture
DECAL_Y_INTERFACE = 88;
document.getElementById("barreOutilCache").style.top = "103px";
document.getElementById("outils").style.top = "103px";
document.getElementById("trajMaitre").style.top = "103px";
document.getElementById("barreTitreCache").style.top = "88px";
document.getElementById("contentCanvas").style.top = "103px";
document.getElementById("titre").style.visibility = "visible";
document.getElementById("options").style.visibility = "visible";
document.getElementById("logo").style.visibility = "visible";
document.getElementById("medaille").style.visibility = "visible";
document.getElementById("barreInfo").style.visibility = "visible";
document.getElementById("titreLogo").style.visibility = "visible";
}
isOpenBarreTitre = !isOpenBarreTitre;
}
function toDegrees(angle) {
return (angle * Math.PI) / 180;
}
function ajouterSupprimerTrajectoires() {
trajectoire = !trajectoire;
updateDuplicatedElements();
genererParcours();
}
function toggleConducteur() {
showconducteur = !showconducteur;
updateDuplicatedElements();
genererParcours();
}
function updateDuplicatedElements() {
document.getElementById("Traj").checked = trajectoire;
document.getElementById("Traj-2").checked = trajectoire;
document.getElementById("AfficherConducteur").checked = showconducteur;
document.getElementById("AfficherConducteur-2").checked = showconducteur;
document.getElementById("showNumero").checked = shownumbers;
document.getElementById("showNumero-2").checked = shownumbers;
}
function changeLargeur() {
var largeurP = document.getElementById("largeurParcours").value;
// Enlever tous les charactères sauf les chiffres
largeurP = largeurP.replace(/[^0-9]/g, "");
if (largeurP != 0) {
canvas.width = ((largeurP * 100) / pixel / unite + MARGE * 2) * scale;
canvasSizeX = canvas.width / scale;
context.scale(scale, scale);
genererParcours();
}
}
function changeLongueur() {
var longueurP = document.getElementById("longueurParcours").value;
// Enlever tous les charactères sauf les chiffres
longueurP = longueurP.replace(/[^0-9]/g, "");
if (longueurP != 0) {
canvas.height = ((longueurP * 100) / pixel / unite + MARGE * 3) * scale;
canvasSizeY = canvas.height / scale;
context.scale(scale, scale);
genererParcours();
}
}
function changeEchelle() {
var echelle = document.getElementById("echelle").value;
if (echelle > 0) {
TAILLE_GRILLAGE = ((100 / pixel) * echelle) / unite;
genererParcours();
}
}
function changeInfos() {
titre = document.getElementById("titreParcours").value;
auteur = document.getElementById("auteurParcours").value;
genererParcours();
}
function log(valeur) {
document.getElementById("texte").innerHTML = valeur;
}
function exportToPNG2() {
//window.open(canvas.toDataURL('image/png'));
var d = canvas.toDataURL("image/png");
var w = window.open("about:blank", "image from canvas");
w.document.write("<img src='" + d + "' alt='from canvas'/>");
}
function exportToPNG(qualite) {
document.getElementById("globalContent").style.display = "none";
var oldScale = scale;
if (qualite == 0) {
// on ne fait rien car on utilise les paramètres par defaut
} else if (qualite == 4) {
zoom(4);
} else if (qualite == 8) {
zoom(8);
}
var canvasimg = document.getElementById("canvasimg");
var fond = document.getElementById("fondImage");
canvasimg.src = canvas.toDataURL("img/png");
canvasimg.style.visibility = "visible";
var conteneurImg = document.getElementById("conteneurImgExport");
conteneurImg.className = "imageExport";
fond.className = "fondExport";
zoom(oldScale);
}
function fermerExport() {
document.getElementById("globalContent").style.display = "block";
//var fond = document.getElementById('fondImage');
var conteneurImg = document.getElementById("conteneurImgExport");
conteneurImg.className = "imageNotExport";
//fond.className ="fondNotExport";
var canvasimg = document.getElementById("canvasimg");
canvasimg.style.visibility = "hidden";
// zoom(1);
zoom(scale);
//canvasimg.style.display='none';
var fond = document.getElementById("fondImage");
fond.className = "fondNoExport";
}
function zoom(niveau) {
if (niveau == "p") {
scale = scale + 0.2;
} else if (niveau == "m") {
scale = scale - 0.2;
} else {
scale = niveau;
}
changeLongueur();
changeLargeur();
genererParcours();
}
function changeUniteMesure() {
var oldUnit = unite;
unite = document.getElementById("uniteMesure").value;
var convertion = unite / oldUnit;
// convertion des longueurs/largeurs
var longueurP =
document.getElementById("longueurParcours").value * convertion;
document.getElementById("longueurParcours").value = Math.round(longueurP);
var largeurP =
document.getElementById("largeurParcours").value * convertion;
document.getElementById("largeurParcours").value = Math.round(largeurP);
changeEchelle();
}
var xBz;
var yBz;
var vitesseTraj = 20;
var vitMax = 100;
function customBez(t, x0, y0, x1, y1, x2, y2, x3, y3) {
var cX = 3 * (x1 - x0),
bX = 3 * (x2 - x1) - cX,
aX = x3 - x0 - cX - bX;
var cY = 3 * (y1 - y0),
bY = 3 * (y2 - y1) - cY,
aY = y3 - y0 - cY - bY;
xBz = aX * Math.pow(t, 3) + bX * Math.pow(t, 2) + cX * t + x0;
yBz = aY * Math.pow(t, 3) + bY * Math.pow(t, 2) + cY * t + y0;
}
function customBezier(x1, y1, x1b, y1b, x2b, y2b, x2, y2) {
var accuracy = 0.01;
context.strokeStyle = "rgba(255, 0, 0, 1)"; // grilles
var newX = x1;
var newY = y1;
var i = 0;
var avance = ((longueurMetre / 100) * accuracy * vitMax) / 13;
var oldX;
var oldY;
var oldX2;
var oldY2;
var oldAngle;
for (i = 0; i <= 1 + accuracy; i += accuracy) {
context.beginPath();
context.moveTo(newX, newY);
if (document.getElementById("VitesseTrajectoires").checked) {
context.lineWidth = 1.5;
context.strokeStyle = getColor(vitesseTraj); // grilles
} else {
context.lineWidth = 1;
context.strokeStyle = "black"; // grilles
}
customBez(i, x1, y1, x1b, y1b, x2b, y2b, x2, y2);
context.lineTo(xBz, yBz);
context.stroke();
if (document.getElementById("VitesseTrajectoires").checked) {
if (i > 0) {
//calcul de l'angle actuel
newAngle = (Math.atan2(newY - yBz, newX - xBz) / Math.PI) * 180;
var diffAngle = oldAngle - newAngle;
if (diffAngle >= 0) {
if (diffAngle > 6) {
vitesseTraj -= avance * 5; // cas d'un virage séré
} else if (diffAngle > 5) {
vitesseTraj -= avance * 3; // cas d'un virage séré
} else if (diffAngle > 4) {
vitesseTraj -= avance * 2; // cas d'un virage séré
} else if (diffAngle > 3) {
vitesseTraj -= avance * 1; // cas d'un virage séré
} else if (diffAngle > 2) {
//vitesseTraj+=avance*0.2;// cas d'un virage séré
} else if (diffAngle > 1.5) {
vitesseTraj += avance * 0.4; // cas d'un virage séré
} else if (diffAngle > 1) {
vitesseTraj += avance * 0.6; // cas d'un virage séré
} else if (diffAngle > 0.5) {
vitesseTraj += avance * 0.8; // cas d'un virage peu séré
} else {
vitesseTraj += avance; // cas d'une ligne a peu pres droite
}
}
if (diffAngle < 0) {
if (diffAngle < -6) {
vitesseTraj -= avance * 5; // cas d'un virage séré
} else if (diffAngle < -5) {
vitesseTraj -= avance * 3; // cas d'un virage séré
} else if (diffAngle < -4) {
vitesseTraj -= avance * 2; // cas d'un virage séré
} else if (diffAngle < -3) {
vitesseTraj -= avance * 1; // cas d'un virage séré
} else if (diffAngle < -2) {
//vitesseTraj+=avance*0.2;// cas d'un virage séré
} else if (diffAngle < -1.5) {
vitesseTraj += avance * 0.4; // cas d'un virage peu séré
} else if (diffAngle < -1) {
vitesseTraj += avance * 0.6; // cas d'un virage peu séré
} else if (diffAngle < -0.5) {
vitesseTraj += avance * 0.8; // cas d'un virage peu séré
} else {
vitesseTraj += avance; // cas d'une ligne a peu pres droite
}
}
oldAngle = newAngle;
} else {
vitesseTraj += avance; // cas d'une ligne droite
}
if (vitesseTraj > vitMax) {
vitesseTraj = vitMax;
}
if (vitesseTraj < 0) {
vitesseTraj = 0;
}
}
newX = xBz;
newY = yBz;
}
context.lineWidth = 1;
}
function getColor(vitesseTraj) {
var colorV = 0;
var colorR = 255;
if (vitesseTraj <= vitMax / 2) {
colorR = 255;
} else {
colorR = 255 - ((vitesseTraj - vitMax / 2) / vitMax) * 255;
}
if (vitesseTraj >= vitMax / 2) {
colorV = 255;
} else {
colorV = (vitesseTraj / vitMax) * 2 * 255;
}
if (colorV > 255) {
colorV = 255;
} else if (colorV < 0) {
colorV = 0;
}
if (colorR > 255) {
colorR = 255;
} else if (colorR < 0) {
colorR = 0;
}
return "rgba(" + Math.round(colorR) + ", " + Math.round(colorV) + ", 0, 1)";
}
function toggleShowNumbers() {
// Function don't get the value from check button, only uses it to change variable value calling this function
shownumbers = !shownumbers;
updateDuplicatedElements();
genererParcours();
}
function exportData(){
var data = saveFileVersion+"\n";
data += JSON.stringify(document.getElementById("titreParcours").value);
data += "\n";
data += JSON.stringify(document.getElementById("auteurParcours").value);
data += "\n";
data += JSON.stringify(nextNumber);
data += "\n";
data += JSON.stringify(listeNumero);
data += "\n";
data += JSON.stringify(nextNumber2);
data += "\n";
data += JSON.stringify(listeNumero2);
data += "\n";
data += JSON.stringify(nextNumber3);
data += "\n";
data += JSON.stringify(listeNumero3);
data += "\n";
data += JSON.stringify(idTunnel);
data += "\n";
data += JSON.stringify(tbTunnels);
data += "\n";
data += JSON.stringify(id);
data += "\n";
data += JSON.stringify(tbObst);
data += "\n";
data += JSON.stringify(idOrdre);
data += "\n";
data += JSON.stringify(ordreObst);
data += "\n";
data += JSON.stringify(document.getElementById("longueurParcours").value);
data += "\n";
data += JSON.stringify(document.getElementById("largeurParcours").value);
data += "\n";
data += JSON.stringify(document.getElementById("echelle").value);
var t = new Blob([data], {type: "text/plain"});
var c = document.createElement("a");
var title = document.getElementById("titreParcours").value;
var author = document.getElementById("auteurParcours").value;
var fname = "course"
if ( title!="" ) {
fname = title;
} else {
var now = new Date();
fname += "_"+now.getFullYear()+(now.getMonth()+1)+now.getDate()+now.getHours()+now.getMinutes()+now.getSeconds();
}
if ( author!="" ) { fname += " ("+author+")"; }
c.download = fname+".amc";
c.href = window.URL.createObjectURL(t);
c.click();
}
function importFile(){
var input = document.createElement('input');
input.type = 'file';
input.accept = '.amc,*';
input.onchange = e => {
// getting a hold of the file reference
var file = e.target.files[0];
var file = e.target.files[0];
// setting up the reader
var reader = new FileReader();
reader.readAsText(file,'UTF-8');
// here we tell the reader what to do when it's done reading...
reader.onload = readerEvent => {
var content = readerEvent.target.result; // this is the content!
const myArray = content.split("\n");
var fileVersion = JSON.parse(myArray[0]);
if (fileVersion=="1") {
title = JSON.parse(myArray[1]);
author = JSON.parse(myArray[2]);
nextNumber = JSON.parse(myArray[3]);
listeNumero = JSON.parse(myArray[4]);
nextNumber2 = JSON.parse(myArray[5]);
listeNumero2 = JSON.parse(myArray[6]);
nextNumber3 = JSON.parse(myArray[7]);
listeNumero3 = JSON.parse(myArray[8]);
idTunnel = JSON.parse(myArray[9]);
tbTunnels = JSON.parse(myArray[10]);
id = JSON.parse(myArray[11]);
tbObst = JSON.parse(myArray[12]);
idOrdre = JSON.parse(myArray[13]);
ordreObst = JSON.parse(myArray[14]);
width = JSON.parse(myArray[15]);
height = JSON.parse(myArray[16]);
grid = JSON.parse(myArray[17]);
}
// Update content
document.getElementById("titreParcours").value = title;
document.getElementById("auteurParcours").value = author;
document.getElementById("longueurParcours").value = width;
document.getElementById("largeurParcours").value = height;
document.getElementById("echelle").value = grid;
changeInfos();
changeLargeur();
changeLongueur();
changeEchelle();
genererParcours();
}
}
input.click();
}
function shortcutAction( event ) {
if (lastDownTarget!=canvas) return;
switch (event.key) {
case "m":
document.getElementById("ModifierTrajectoires").checked = !document.getElementById("ModifierTrajectoires").checked;
break;
}
// formas de tunel
if (overTunnelComplet>=0 || overTunnelId>=0) {
var tunnelid = overTunnelComplet;
if ( tunnelid<0 ) { tunnelid = overTunnelId; }
switch (event.key) {
case "1":
// suponemos y comprobamos que el indice del vector coincide con el id del tunel
if ( tbTunnels[tunnelid][0] == tunnelid ) {
tbTunnels[tunnelid][4] = tbTunnels[tunnelid][2];
tbTunnels[tunnelid][6] = tbTunnels[tunnelid][2];
tbTunnels[tunnelid][8] = tbTunnels[tunnelid][2];
tbTunnels[tunnelid][10] = tbTunnels[tunnelid][2];
tbTunnels[tunnelid][12] = tbTunnels[tunnelid][2];
tbTunnels[tunnelid][14] = tbTunnels[tunnelid][2];
tbTunnels[tunnelid][16] = tbTunnels[tunnelid][2];
tbTunnels[tunnelid][18] = tbTunnels[tunnelid][2];
tbTunnels[tunnelid][20] = tbTunnels[tunnelid][2];
}
break;
case "2":
// suponemos y comprobamos que el indice del vector coincide con el id del tunel
if ( tbTunnels[tunnelid][0] == tunnelid ) {
tbTunnels[tunnelid][3] = tbTunnels[tunnelid][1];
tbTunnels[tunnelid][5] = tbTunnels[tunnelid][1];
tbTunnels[tunnelid][7] = tbTunnels[tunnelid][1];
tbTunnels[tunnelid][9] = tbTunnels[tunnelid][1];
tbTunnels[tunnelid][11] = tbTunnels[tunnelid][1];
tbTunnels[tunnelid][13] = tbTunnels[tunnelid][1];
tbTunnels[tunnelid][15] = tbTunnels[tunnelid][1];
tbTunnels[tunnelid][17] = tbTunnels[tunnelid][1];
tbTunnels[tunnelid][19] = tbTunnels[tunnelid][1];
}
break;
}
genererParcours();
}
// temporalmente, si se está encima de un obstaculo no se permite el atajo porque si no se mueven el nuevo elemento y
// sobre el que se encuentra el ratón al definir la posición del nuevo elemento
if (isOverObstacle()) return;
switch (event.key) {
case "j":
ajouterHaie();
break;
case "n":
ajouterNumero(1);
break;
case "t":
ajouterTunnel(6);
break;
case "T":
ajouterTunnel(3);
break;
case "+":
zoom('p')
break;
case "-":
zoom('m')
break;
}
// console.log(event.key);
}

Some files were not shown because too many files have changed in this diff Show More