Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
50
Task/Pinstripe-Printer/Wren/pinstripe-printer-1.wren
Normal file
50
Task/Pinstripe-Printer/Wren/pinstripe-printer-1.wren
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* gcc -O3 -std=c11 -shared -o printer.so -fPIC -I./include printer.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 Printer {\n"
|
||||
"foreign static printFile(name) \n"
|
||||
"} \n";
|
||||
|
||||
void C_printFile(WrenVM* vm) {
|
||||
const char *arg = wren->getSlotString(vm, 1);
|
||||
char command[strlen(arg) + 4];
|
||||
strcpy(command, "lp ");
|
||||
strcat(command, arg);
|
||||
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, "printer", source);
|
||||
core->registerClass(ctx, "printer", "Printer", NULL, NULL);
|
||||
core->registerFn(ctx, "printer", "static Printer.printFile(_)", C_printFile);
|
||||
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;
|
||||
}
|
||||
52
Task/Pinstripe-Printer/Wren/pinstripe-printer-2.wren
Normal file
52
Task/Pinstripe-Printer/Wren/pinstripe-printer-2.wren
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import "graphics" for Canvas, Color, ImageData
|
||||
import "dome" for Window
|
||||
import "plugin" for Plugin
|
||||
|
||||
Plugin.load("printer")
|
||||
|
||||
import "printer" for Printer
|
||||
|
||||
class Main {
|
||||
construct new() {
|
||||
Window.title = "Pinstripe - printer"
|
||||
_width = 842
|
||||
_height = 595
|
||||
Canvas.resize(_width, _height)
|
||||
Window.resize(_width, _height)
|
||||
var colors = [
|
||||
Color.hex("FFFFFF"), // white
|
||||
Color.hex("000000") // black
|
||||
]
|
||||
pinstripe(colors)
|
||||
}
|
||||
|
||||
pinstripe(colors) {
|
||||
var w = _width
|
||||
var h = (_height/7).floor
|
||||
for (b in 1..11) {
|
||||
var x = 0
|
||||
var ci = 0
|
||||
while (x < w) {
|
||||
var y = h * (b - 1)
|
||||
Canvas.rectfill(x, y, b, h, colors[ci%2])
|
||||
x = x + b
|
||||
ci = ci + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
var img = ImageData.create("pinstripe", _width, _height)
|
||||
for (x in 0..._width) {
|
||||
for (y in 0..._height) img.pset(x, y, Canvas.pget(x, y))
|
||||
}
|
||||
img.saveToFile("pinstripe.png")
|
||||
Printer.printFile("pinstripe.png")
|
||||
}
|
||||
|
||||
update() {}
|
||||
|
||||
draw(alpha) {}
|
||||
}
|
||||
|
||||
var Game = Main.new()
|
||||
Loading…
Add table
Add a link
Reference in a new issue