Skip to content

Commit

Permalink
Got cows to fall.
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Yoo committed Apr 17, 2009
1 parent b0f48f3 commit e1a2fb6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/image-lift.ss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
[bitmap (send a-snip get-bitmap)]
[replacement-snip (make-object string-snip%
(format "(-kernel-create-image ~s)"
(string-append "/" file-name)))])
file-name))])
(send a-text set-position
(send a-text get-snip-position a-snip)
(+ (send a-text get-snip-position a-snip)
Expand Down
46 changes: 46 additions & 0 deletions support/js/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ org.plt.WorldKernel = {};
};


org.plt.WorldKernel._kernelCreateImage = function(path) {
return new FileImage(path.toString());
};

org.plt.WorldKernel.nwRectangle = function(w, h, s, c) {
return new RectangleImage(
org.plt.types.NumberTower.toInteger(w),
org.plt.types.NumberTower.toInteger(h),
s,
c);
}



// SceneImage: primitive-number primitive-number (listof image) -> Scene
function SceneImage(width, height, children) {
Expand Down Expand Up @@ -144,6 +157,39 @@ org.plt.WorldKernel = {};
};


function FileImage(path) {
this.img = new Image();
this.img.src = path;
// We should do something asynchronous here
// for onload, since we don't know at
// this time what the file size should be.
}

FileImage.prototype.render = function(ctx, x, y) {
ctx.drawImage(this.img, x, y);
};



function RectangleImage(width, height, style, color) {
this.width = width;
this.height = height;
this.style = style;
this.color = color;
}

RectangleImage.prototype.render = function(ctx, x, y) {
this.fillStyle = this.color;
if (this.style.toLowerCase() == "outline") {
ctx.strokeRect(x, y, x+this.width, y+this.height);
} else {
ctx.fillRect(x, y, x+this.width, y+this.height);
}
};




function TextImage(msg, size, color) {
this.msg = msg;
this.size = size;
Expand Down

0 comments on commit e1a2fb6

Please sign in to comment.