{{template "head" "Formats"}}
<div style="margin: 0">
<h1>DRM database formats</h1>
<p><a href="/">Back to index</a></p>
<h2 id="in-formats">Input formats</h2>
{{define "pct-cell"}}
<td style="color: {{pctColor .}};">{{printf "%.0f%%" .}}</td>
{{end}}
<table>
<thead>
<tr>
<th rowspan="2">Modifier</th>
<th rowspan="2">Format</th>
<th colspan="{{len .Planes}}">Planes</th>
<th colspan="{{len .Drivers}}">Drivers</th>
</tr>
<tr>
{{range $plane, $_ := .Planes}}
<th><a href="?plane={{printf "%d" $plane}}" title="Only show {{$plane.String}} plane formats">{{$plane.String}}</a></th>
{{end}}
{{range $drv, $_ := .Drivers}}
<th><a href="?driver={{$drv}}" title="Only show {{$drv}} formats">{{$drv}}</a></th>
{{end}}
</tr>
</thead>
<tbody>
{{range .Formats}}
<tr>
{{$row := .}}
<td class="pre" title="{{printf "0x%X" .Modifier}}">{{.Modifier}}</td>
<td class="pre" title="{{printf "0x%X" .Format}}">{{.Format}}</td>
{{range $plane, $total := $.Planes}}
{{template "pct-cell" (pct (index $row.Planes $plane) $total)}}
{{end}}
{{range $drv, $total := $.Drivers}}
{{template "pct-cell" (pct (index $row.Drivers $drv) $total)}}
{{end}}
</tr>
{{end}}
</tbody>
</table>
</div>