Skip to content

Instantly share code, notes, and snippets.

@basuke
Created September 18, 2020 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basuke/53f8b3be5bc49b3dbe48719d06304794 to your computer and use it in GitHub Desktop.
Save basuke/53f8b3be5bc49b3dbe48719d06304794 to your computer and use it in GitHub Desktop.
JPEG rotation. Copy piano.jpg from `examples/commodetto/docs/piano.jpg`
import JPEG from "commodetto/readJPEG";
import Poco from "commodetto/Poco";
import Resource from "Resource";
import config from "mc/config";
let poco = new Poco(screen, {rotation: config.rotation});
let gray = poco.makeColor(128, 128, 128);
poco.begin()
poco.fillRectangle(gray, 0, 0, poco.width, poco.height);
poco.end();
let jpeg = new JPEG(new Resource("piano.jpg"));
let block;
while (block = jpeg.read()) {
poco.begin(block.x, block.y, block.width, block.height);
poco.drawBitmap(block, block.x, block.y);
poco.end();
}
{
"include": [
"$(MODDABLE)/examples/manifest_base.json",
"$(MODDABLE)/examples/manifest_commodetto.json"
],
"modules": {
"*": [
"./main"
],
"commodetto/readJPEG": "$(COMMODETTO)/commodettoReadJPEG"
},
"data": {
"*": [
"./piano"
]
},
"config": {
"rotation": 270
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment