Perspective is related to 3D space and is relative to the origin in pixels. First you should work with a larger value for your perspective (say 1000). Second, use a modifier to set the translation of your surface with respect to your context. Positive values position the element closer to the viewer, negative values further away.
Note: Moving your translateZ value by half does not change your surface size by that factor! It only moves it from your perspective that value closer or further away along the origin axis. Run the example below and change the translate to -1000 and you will see.
Example jsBin
var mainContext = Engine.createContext();
var contextPerspective = 1000;
mainContext.setPerspective(contextPerspective);
var surface = new Surface({
content: 'Background',
transform: Transform.translate(0, 0, 0.002),
properties: {
backgroundColor: 'rgba(0,0,0,0.1)'
}
});
var surfacemod = new Modifier({
origin: [0.5, 0.5],
align: [0.5, 0.5]
});
mainContext.add(surfacemod).add(surface);
surfacemod.setTransform(Transform.translate(0, 0, -500));
Edit: To find z transform value based on width of context
Example jsBin (width)
Example jsBin (Image width or heigh based on context size)
var surfacemod = new Modifier({
size: [200, 100],
origin: [0.5, 0.5],
align: [0.5, 0.5]
});
var contextSize = mainContext.getSize();
var surfaceSize = surface.getSize();
var percentage = (contextSize[0]- surfaceSize[0]) / contextSize[0];
var transZ = contextPerspective * percentage;
surfacemod.setTransform(Transform.translate(0, 0, transZ));