Merge pull request #35 from vishesh/master

Implement underlay/offset, overlay/offset and empty-image
This commit is contained in:
Vishesh Yadav 2015-06-08 18:37:27 -04:00
commit ed08271fdf
4 changed files with 44 additions and 1 deletions

View File

@ -1,13 +1,15 @@
#lang s-exp "../../lang/base.rkt"
;; Image functions that be implemented using racket based on primitives
;; NOTE: Modifications here may require rebuilding of Whalesong
(require "main.rkt"
"../../lang/for.rkt"
"../../lang/posn.rkt")
(provide place-images
place-images/align)
place-images/align
empty-image)
; place-images : (listof image?) (listof posn?) image? -> image?
(define (place-images images posns scene)
@ -20,3 +22,5 @@
(for/fold ([acc scene])
([img images] [posn posns])
(place-image/align img (posn-x posn) (posn-y posn) x-place y-place acc)))
(define empty-image (rectangle 0 0 "solid" "black"))

View File

@ -474,6 +474,22 @@ EXPORTS['overlay/xy'] =
jsnums.toFixnum(deltaY));
});
EXPORTS['overlay/offset'] =
makePrimitiveProcedure(
'overlay/offset',
4,
function(MACHINE) {
var img1 = checkImage(MACHINE, "overlay/offset", 0);
var deltaX = checkReal(MACHINE, "overlay/offset", 1);
var deltaY = checkReal(MACHINE, "overlay/offset", 2);
var img2 = checkImage(MACHINE, "overlay/offset", 3);
var middleX = (img1.getWidth() - img2.getWidth()) / 2;
var middleY = (img1.getHeight() - img2.getHeight()) / 2;
return makeOverlayImage(img1,
img2,
jsnums.toFixnum(middleX + deltaX),
jsnums.toFixnum(middleY + deltaY));
});
EXPORTS['overlay/align'] =
@ -540,6 +556,23 @@ EXPORTS['underlay/xy'] =
-(jsnums.toFixnum(deltaY)));
});
EXPORTS['underlay/offset'] =
makePrimitiveProcedure(
'underlay/offset',
4,
function(MACHINE) {
var img1 = checkImage(MACHINE, "underlay/offset", 0);
var deltaX = checkReal(MACHINE, "underlay/offset", 1);
var deltaY = checkReal(MACHINE, "underlay/offset", 2);
var img2 = checkImage(MACHINE, "underlay/offset", 3);
var middleX = (img1.getWidth() - img2.getWidth()) / 2;
var middleY = (img1.getHeight() - img2.getHeight()) / 2;
return makeOverlayImage(img2,
img1,
-jsnums.toFixnum(middleX + deltaX),
-jsnums.toFixnum(middleY + deltaY));
});
EXPORTS['underlay/align'] =
makePrimitiveProcedure(
'underlay/align',

View File

@ -19,9 +19,11 @@
video/url
play-sound
overlay
overlay/offset
overlay/xy
overlay/align
underlay
underlay/offset
underlay/xy
underlay/align
beside

View File

@ -5,9 +5,11 @@
(provide text
text/font
overlay
overlay/offset
overlay/xy
overlay/align
underlay
underlay/offset
underlay/xy
underlay/align
beside
@ -101,9 +103,11 @@
text
text/font
overlay
overlay/offset
overlay/xy
overlay/align
underlay
underlay/offset
underlay/xy
underlay/align
beside