2014-07-14 53 views
2

如何設置在writeMessage()函數中顯示的文本的背景顏色? 下面是我的腳本的一部分。如何在動態js圖層中設置文本的背景顏色?

function initStage() { 
    var stage = new Kinetic.Stage({ 
     container: 'somediv', 
     width: 565, 
     height: 570 
    }); 

    var messageLayer = new Kinetic.Layer(); 
    stage.add(messageLayer); 

    writeMessage(messageLayer, 'somemessage',300,300); 
    } 
    ... 
function writeMessage(messageLayer, message, xp,yp) { 
    var context = messageLayer.getContext(); 
    messageLayer.clear(); 
    context.setAttr('font', '20pt Calibri'); 
    //how can i set background color of text here? 
    context.fillStyle = 'black'; 
    context.fillText(message, xp, yp); 
    } 

回答

相關問題