1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
| <!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
<style>
td{
color:black;
border-style: solid;
border-width: 1px;
background:red;
border-color:black;
}
</style>
</head>
<body>
<header></header>
<main>
<table>
<thead>
<tr>
<th>Sans rognage</th>
<th>Avec rognage</th>
<tr>
</thead>
<tbody>
<tr>
<td>
<table>
<tr>
<td id=11 width=100 height=100>/>
<td id=12 width=100 height=100/>
</tr>
<tr>
<td id=13 width=100 height=100/>
<td id=14 width=100 height=100/>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td id=21 width=100 height=100/>
<td id=22 width=100 height=100/>
</tr>
<tr>
<td id=23 width=100 height=100/>
<td id=24 width=100 height=100/>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<style>
</style>
<script>
let GenAff_di = {};//Dictionnaire des instances des boutons généré automatiquement
class GenAff {
constructor({
id = "GenAff_D",
optionAff={
angle:270,//Largeur piste
angleRotation:90,//Angle de rotation globale
REchel:46,//Rayon piste hors maxi - mini
LEchel:11,//largeur piste hors maxi - mini
SEchel:1,//Largeur Contour Echel
},
}={})
{
this.id=id;
this.optionAff = optionAff
this.container=document.getElementById(this.id);
this.container.classList.add('GenAff');
this.#setHTML()
this.containerSVG=this.container.querySelector("svg")
this.containerSVG.classList.add('GenAff_svg')
this.containerGauge=this.container.querySelector(".GenAff_Gauge")
this.containerGaugeRot=this.container.querySelector(".GenAff_GaugeRot")
this.containerBord = document.createElementNS("http://www.w3.org/2000/svg", "path");
this.#drawGaugeTrack()
}
#setHTML() {
this.container.innerHTML = /*html*/`
<svg class="GenAff_svg" width="100%" height="100%">
<g class="GenAff_Gauge"
transform=" translate(50 50)"
transform-origin=" 50 50"
>
<g class="GenAff_GaugeRot">
<g class="GenAff_Track"></g>
</g>
</g>
</svg>
`
}
#polarToCartesian(centerX, centerY, radius, angleInDegrees) {
let angleInRadians = (angleInDegrees) * Math.PI / 180.0
return {
x: centerX + (radius * Math.cos(angleInRadians)),
y: centerY + (radius * Math.sin(angleInRadians))
};
}
#describeArc(x, y, radius, startAngle, endAngle){
let start = this.#polarToCartesian(x, y, radius, endAngle);
let end = this.#polarToCartesian(x, y, radius, startAngle);
let largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";
let d = [
"M", start.x, start.y,
"A", radius, radius, 0, largeArcFlag, 0, end.x, end.y
].join(" ");
return d;
}
#drawGaugeTrack(){
const demiAngle = this.optionAff.angle/2
//rotation
this.containerGaugeRot.style.transform = `rotate(${this.optionAff.angleRotation}deg)`;
//Bordure
let xViewbox=100
let yViewbox=100
//const bord = document.createElementNS("http://www.w3.org/2000/svg", "path");
if (this.optionAff.angle<120){
let rptinter=this.optionAff.Rechel-this.optionAff.Lechel-(50-this.optionAff.Rechel)
let angleptinter=demiAngle+5
let pt1 = this.#polarToCartesian(0,0,rptinter,-angleptinter)
let pt2 = this.#polarToCartesian(0,0,rptinter,angleptinter)
this.containerBord.setAttribute("d",`
${this.#describeArc(0, 0, 50 , -demiAngle-5, demiAngle+5,)}
L ${pt1['x']} ${pt1['y']}
L 0 -10
L 0 10
L ${pt2['x']} ${pt2['y']}
z
`);
xViewbox=50*Math.abs(Math.sin((90-demiAngle)))
yViewbox=50+this.optionAff.Raxe
// this.containerGauge.style.transform = `translate(${50-xViewbox/2}px, 50px)`;
}
// this.containerSVG.setAttribute("viewBox",`0 0 ${xViewbox} ${yViewbox}`)
this.containerGaugeRot.insertAdjacentElement('afterbegin',this.containerBord);
this.containerBord.setAttribute("class", "GenAff_Bord");
this.containerBord.setAttribute("stroke", "lime");
this.containerBord.setAttribute("fill", "lime");
}
}
GenAff_di[11] = new GenAff({
id:11,
optionAff:{
angle:60,
angleRotation:0,
Rechel:46,//Rayon echelle hors mini - maxi
Lechel:12,//largeur echelle hors mini - maxi
SEchel:1,//Largeur Contour Echel
}
})
GenAff_di[12] = new GenAff({
id:12,
optionAff:{
angle:60,
angleRotation:90,
Rechel:46,//Rayon echelle hors mini - maxi
Lechel:12,//largeur echelle hors mini - maxi
SEchel:1,//Largeur Contour Echel
}
})
GenAff_di[13] = new GenAff({
id:13,
optionAff:{
angle:60,
angleRotation:180,
Rechel:46,//Rayon echelle hors mini - maxi
Lechel:12,//largeur echelle hors mini - maxi
SEchel:1,//Largeur Contour Echel
}
})
GenAff_di[14] = new GenAff({
id:14,
optionAff:{
angle:60,
angleRotation:270,
Rechel:46,//Rayon echelle hors mini - maxi
Lechel:12,//largeur echelle hors mini - maxi
SEchel:1,//Largeur Contour Echel
}
})
</script>
</main>
<footer></footer>
</body>
</html> |
Partager