Sysrq147
Sysrq147

Reputation: 1367

Famo.us Surface - Image as background

I am experimenting with Famo.us framework. Can Surface have image as background? How can i set that. I have tried wth:

   // your app here
    var bg = new Surface({
     properties: {

    backgroundImage: "url(images/background.png')"
  }
    });

Upvotes: 1

Views: 539

Answers (1)

johntraver
johntraver

Reputation: 3612

You need to set the size of the surface. You can also additionally set the size of the backgroundImage with backgroundSize.. Here is what I did.. Hope it helps!

var Engine    = require('famous/core/Engine');
var Surface   = require('famous/core/Surface');
var Modifier  = require('famous/core/Modifier');

var context = Engine.createContext();

var surface = new Surface({
  size:[200,200],
  properties:{
    backgroundImage:  'url(content/images/famous_symbol_transparent.png)',
    backgroundSize:   '200px 200px',
    backgroundRepeat: 'no-repeat'
  }
});

context.add(new Modifier({origin:[0.5,0.5]})).add(surface);

Upvotes: 4

Related Questions