added ArduboyFx begin drawBitmap and display to the crate also added a fxdata-converter.html file to the docs
This commit is contained in:
parent
9248c9f2ac
commit
ddf419f702
10 changed files with 3218 additions and 2682 deletions
363
docs/fxdata-converter.html
Normal file
363
docs/fxdata-converter.html
Normal file
|
@ -0,0 +1,363 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link
|
||||
rel="icon"
|
||||
href="https://upload.wikimedia.org/wikipedia/commons/0/0f/Original_Ferris.svg"
|
||||
type="image/svg+xml"
|
||||
/>
|
||||
<title>ZennDev1337 Image Converter</title>
|
||||
</head>
|
||||
|
||||
<body onload="setup(this);">
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
background-color: black;
|
||||
color: azure;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Courier New;
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
font-size: xx-large;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
min-height: calc(100vh - 50px);
|
||||
}
|
||||
|
||||
.footer {
|
||||
font-family: Courier New;
|
||||
text-align: center;
|
||||
font-size: large;
|
||||
font-weight: 600;
|
||||
height: 50px;
|
||||
|
||||
color: #e7e7e7;
|
||||
}
|
||||
|
||||
.footer > a {
|
||||
font-family: Courier New;
|
||||
text-align: center;
|
||||
font-size: large;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
color: #e7e7e7;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.sticky {
|
||||
bottom: 0;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
background-color: #281c1c;
|
||||
color: azure;
|
||||
border: dotted 2px #ce422b;
|
||||
width: 670px;
|
||||
height: 300px;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.title > p {
|
||||
padding-left: 20px;
|
||||
margin: 0;
|
||||
padding-right: 20px;
|
||||
color: #e7e7e7;
|
||||
font-size: xx-large;
|
||||
}
|
||||
|
||||
.title {
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.separator {
|
||||
border-top: solid #281c1c;
|
||||
border-bottom: none;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
margin-top: 40px;
|
||||
width: clamp(700px, 70vw, 1200px);
|
||||
}
|
||||
|
||||
.image-container {
|
||||
margin-top: 40px;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: medium;
|
||||
}
|
||||
|
||||
.txtHead {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.topnav {
|
||||
background-color: #000000;
|
||||
height: 47px;
|
||||
}
|
||||
|
||||
.topnav a {
|
||||
color: #f2f2f2;
|
||||
text-align: center;
|
||||
padding: 14px 16px;
|
||||
text-decoration: none;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.topnav a:hover {
|
||||
background-color: #ddd;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.topnav a.active {
|
||||
background-color: #281c1c;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.topnav .icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.topnav a:not(:first-child) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.topnav a.icon {
|
||||
float: right;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.topnav.responsive {
|
||||
position: relative;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.topnav {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.topnav.responsive a.icon {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.topnav.responsive a {
|
||||
float: none;
|
||||
display: block;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<div class="wrapper">
|
||||
<div class="topnav" id="myTopnav">
|
||||
<a
|
||||
href="https://zenndev1337.github.io/Rust-for-Arduboy/index.html"
|
||||
><nobr>Rust for Arduboy</nobr></a
|
||||
>
|
||||
<a
|
||||
href="https://zenndev1337.github.io/Rust-for-Arduboy/image-converter.html"
|
||||
><nobr>Image Converter</nobr></a
|
||||
>
|
||||
<a
|
||||
href="https://zenndev1337.github.io/Rust-for-Arduboy/tile-converter.html"
|
||||
><nobr>Tile Converter</nobr></a
|
||||
>
|
||||
<a
|
||||
href="https://zenndev1337.github.io/Rust-for-Arduboy/sprite-converter.html"
|
||||
><nobr>Sprite Converter</nobr></a
|
||||
>
|
||||
<a
|
||||
href="https://zenndev1337.github.io/Rust-for-Arduboy/arduboy-file-converter.html"
|
||||
><nobr>.arduboy Generator</nobr></a
|
||||
>
|
||||
<a
|
||||
href="https://zenndev1337.github.io/Rust-for-Arduboy/fxdata-converter.html"
|
||||
class="active"
|
||||
><nobr>fxdata.h Converter</nobr></a
|
||||
>
|
||||
<a
|
||||
href="javascript:void(0);"
|
||||
class="icon"
|
||||
onclick="myFunction()"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
class="bi bi-list"
|
||||
viewBox="0 0 16 16"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
<div class="title">
|
||||
<p>Drop your fxdata.h here</p>
|
||||
</div>
|
||||
<hr class="separator" />
|
||||
<div class="image-container">
|
||||
<div id="image-container"></div>
|
||||
</div>
|
||||
<hr class="separator" />
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<a href="https://github.com/ZennDev1337/" target="_blank"
|
||||
>By ZennDev1337</a
|
||||
>
|
||||
</footer>
|
||||
<script language="JavaScript">
|
||||
function myFunction() {
|
||||
var x = document.getElementById("myTopnav");
|
||||
if (x.className === "topnav") {
|
||||
x.className += " responsive";
|
||||
} else {
|
||||
x.className = "topnav";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script language="JavaScript">
|
||||
function swapImage(t, e) {
|
||||
var r = t.getAttribute("data-srcnm");
|
||||
t.removeAttribute("srcset"),
|
||||
r || t.setAttribute("data-srcnm", t.src),
|
||||
(t.src = e);
|
||||
}
|
||||
function setOriginal(t) {
|
||||
var e = "",
|
||||
r = "";
|
||||
(r = t.getAttribute("data-srcmd")),
|
||||
(e = t.getAttribute("data-srcnm")),
|
||||
r
|
||||
? ((t.src = r), t.removeAttribute("data-srcmd"))
|
||||
: ((t.src = e), t.removeAttribute("data-srcnm"));
|
||||
}
|
||||
function swapImageMD(t, e) {
|
||||
t.setAttribute("data-srcmd", t.src), (t.src = e);
|
||||
}
|
||||
function jsready(t) {
|
||||
/in/.test(document.readyState)
|
||||
? setTimeout("jsready(" + t + ")", 9)
|
||||
: t();
|
||||
}
|
||||
jsready(function () {
|
||||
var t = window.devicePixelRatio ? window.devicePixelRatio : 1;
|
||||
if (t > 1)
|
||||
for (
|
||||
var e = document.getElementsByTagName("img"), r = 0;
|
||||
r < e.length;
|
||||
r++
|
||||
)
|
||||
e[r].getAttribute("data-src2x") &&
|
||||
(e[r].setAttribute(
|
||||
"data-src-orig",
|
||||
e[r].getAttribute("src")
|
||||
),
|
||||
e[r].setAttribute(
|
||||
"src",
|
||||
e[r].getAttribute("data-src2x")
|
||||
));
|
||||
});
|
||||
|
||||
function setup(body) {
|
||||
body.ondragover = function () {
|
||||
return false;
|
||||
};
|
||||
body.ondragend = function () {
|
||||
return false;
|
||||
};
|
||||
body.ondrop = function (e) {
|
||||
// Prevent the browser from showing the dropped file
|
||||
e.preventDefault();
|
||||
// Get the image data
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
//console.log(this.result);
|
||||
convertCtoRust(this.result);
|
||||
};
|
||||
reader.readAsText(e.dataTransfer.files[0]);
|
||||
// var imageData = getImageData(e);
|
||||
|
||||
// // If there is some data, add it to the page
|
||||
// if (imageData !== null) {
|
||||
// addDroppedElement(imageData);
|
||||
// }
|
||||
};
|
||||
}
|
||||
|
||||
function convertCtoRust(file) {
|
||||
var lines = file.split("\n");
|
||||
var resultString = "";
|
||||
var droppedImageCode = document.createElement("textarea");
|
||||
droppedImageCode.className = "code";
|
||||
|
||||
droppedImageCode.style.width = "698px";
|
||||
droppedImageCode.rows = "20";
|
||||
var imageContainer = document.getElementById("image-container");
|
||||
imageContainer.innerHTML = "";
|
||||
imageContainer.appendChild(droppedImageCode);
|
||||
var regexPattern = /\s+/g;
|
||||
for (var line of lines) {
|
||||
if (!line) {
|
||||
resultString += "\n";
|
||||
}
|
||||
if (line.includes("//")) {
|
||||
resultString += `${line.replace(regexPattern, " ")}\n`;
|
||||
}
|
||||
if (line.includes("/***")) {
|
||||
var words = line.split(" ");
|
||||
words.pop();
|
||||
words.shift();
|
||||
resultString += `// ${words}\n// Convertet to Rust with https://zenndev1337.github.io/Rust-for-Arduboy/fxdata-converter.html`;
|
||||
}
|
||||
if (line.includes("constexpr")) {
|
||||
var words = line.replace(regexPattern, " ").split(" ");
|
||||
for (i in words) {
|
||||
if (words[i] === "") delete words[i];
|
||||
}
|
||||
var type = "";
|
||||
var cType = words[1];
|
||||
switch (cType) {
|
||||
case "uint16_t":
|
||||
type = "u16";
|
||||
break;
|
||||
case "uint24_t":
|
||||
type = "u32";
|
||||
break;
|
||||
case "uint32_t":
|
||||
type = "u32";
|
||||
break;
|
||||
case "uint8_t":
|
||||
type = "u8";
|
||||
break;
|
||||
default:
|
||||
type = "???";
|
||||
}
|
||||
resultString += `const ${words[2]}:${type} = ${words[4]}\n`;
|
||||
}
|
||||
}
|
||||
var result = resultString.split("\n");
|
||||
result.shift();
|
||||
resultString = result.join("\n");
|
||||
droppedImageCode.innerHTML = resultString;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue