我试图在这里修改这个例子
https://github.com/Famous/examples/tree/master/src/examples/surfaces/ImageSurface
我的目标是在某种容器的子修饰符下制作图像。然后我可以setTransform
对这个修饰符做移动图像。
var Engine = require("famous/core/Engine");
var ContainerSurface = require("famous/surfaces/ContainerSurface");
var Modifier = require("famous/core/Modifier");
var ImageSurface = require("famous/surfaces/ImageSurface");
var mainCtx = Engine.createContext();
var image = new ImageSurface({
size: [200, 200]
});
var container = new ContainerSurface({
size: [200, undefined],
properties:{
backgroundColor: 'blue',
overflow: 'hidden'
}
});
image.setContent("content/famous_symbol.svg");
mainCtx.add(container).add(new Modifier({origin: [0, 0]})).add(image);
我希望上面的代码会在左上角显示徽标,然后是蓝色背景。但到目前为止,我根本没有看到图像出现。
有什么帮助吗?
更新 1:
我意识到做这项工作:
container.add(new Modifier({origin: [0, 0]})).add(image);
mainCtx.add(container);
这有点奇怪,因为我认为它与此相同:
mainCtx.add(container).add(new Modifier({origin: [0, 0]})).add(image);
有人可以告诉我区别吗?