var drawComponent = Ext.create('Ext.draw.Component', {
viewBox: false,
items: [{
type: 'circle',
fill: '#ffc',
radius: 100,
x: 100,
y: 100
}]
});
Ext.create('Ext.Window', {
width: 230,
height: 230,
layout: 'fit',
items: [drawComponent]
}).show();
复制代码
作者: @→Epoch 时间: 2012-6-29 00:41
Interacting with a Sprite
Now that we've created a draw surface with a sprite in it, let's dive into how to interact with the sprite. We can get a handle to the sprite we want to modify by adding that sprite imperatively to the surface:
// Create a draw component
var drawComponent = Ext.create('Ext.draw.Component', {
viewBox: false
});
// Create a window to place the draw component in
Ext.create('Ext.Window', {
width: 220,
height: 230,
layout: 'fit',
items: [drawComponent]
}).show();
// Add a circle sprite
var myCircle = drawComponent.surface.add({
type: 'circle',
x: 100,
y: 100,
radius: 100,
fill: '#cc5'
});
// Now do stuff with the sprite, like changing its properties: