Implement overlay/offset and underlay/offset functions in image

This commit is contained in:
Vishesh Yadav 2015-06-08 17:40:09 -04:00
parent 4474eda64f
commit e5e0ee40b4
3 changed files with 39 additions and 0 deletions

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