Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,53 @@
|
|||
/* gcc -O3 -std=c11 -shared -o pipeconv.so -fPIC -I./include pipeconv.c */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "dome.h"
|
||||
|
||||
static DOME_API_v0* core;
|
||||
static WREN_API_v0* wren;
|
||||
|
||||
static const char* source = ""
|
||||
"class PipeConv {\n"
|
||||
"foreign static convert(from, to) \n"
|
||||
"} \n";
|
||||
|
||||
void C_convert(WrenVM* vm) {
|
||||
const char *from = wren->getSlotString(vm, 1);
|
||||
const char *to = wren->getSlotString(vm, 2);
|
||||
char command[strlen(from) + strlen(to) + 10];
|
||||
strcpy(command, "convert ");
|
||||
strcat(command, from);
|
||||
strcat(command, " ");
|
||||
strcat(command, to);
|
||||
int res = system(command);
|
||||
}
|
||||
|
||||
DOME_EXPORT DOME_Result PLUGIN_onInit(DOME_getAPIFunction DOME_getAPI, DOME_Context ctx) {
|
||||
core = DOME_getAPI(API_DOME, DOME_API_VERSION);
|
||||
wren = DOME_getAPI(API_WREN, WREN_API_VERSION);
|
||||
core->registerModule(ctx, "pipeconv", source);
|
||||
core->registerClass(ctx, "pipeconv", "PipeConv", NULL, NULL);
|
||||
core->registerFn(ctx, "pipeconv", "static PipeConv.convert(_,_)", C_convert);
|
||||
return DOME_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DOME_EXPORT DOME_Result PLUGIN_preUpdate(DOME_Context ctx) {
|
||||
return DOME_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DOME_EXPORT DOME_Result PLUGIN_postUpdate(DOME_Context ctx) {
|
||||
return DOME_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DOME_EXPORT DOME_Result PLUGIN_preDraw(DOME_Context ctx) {
|
||||
return DOME_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DOME_EXPORT DOME_Result PLUGIN_postDraw(DOME_Context ctx) {
|
||||
return DOME_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DOME_EXPORT DOME_Result PLUGIN_onShutdown(DOME_Context ctx) {
|
||||
return DOME_RESULT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
import "graphics" for Canvas, ImageData
|
||||
import "dome" for Window
|
||||
import "plugin" for Plugin
|
||||
|
||||
Plugin.load("pipeconv")
|
||||
|
||||
import "pipeconv" for PipeConv
|
||||
|
||||
class ConvertPPM {
|
||||
construct new(fileName, fileName2, width, height) {
|
||||
Window.resize(width, height)
|
||||
Canvas.resize(width, height)
|
||||
Window.title = "Convert PPM file via pipe"
|
||||
// convert .ppm file to .jpg via a pipe
|
||||
PipeConv.convert(fileName, fileName2)
|
||||
// load and display .jpg file
|
||||
var image = ImageData.loadFromFile(fileName2)
|
||||
image.draw(0, 0)
|
||||
}
|
||||
|
||||
init() {}
|
||||
|
||||
update() {}
|
||||
|
||||
draw(alpha) {}
|
||||
}
|
||||
|
||||
var Game = ConvertPPM.new("output.ppm", "output_piped.jpg", 350, 350)
|
||||
Loading…
Add table
Add a link
Reference in a new issue