I am trying to work with KineticJs, and want to have objects, so I can handle the elements easily.
Here is my code. It won't work and I don't know why. (I don't really know oop, just learning)
$(function(){
var stage = new Kinetic.Stage({
container: 'gridalea',
width: 172,
height: 720
});
var color_layer = new Kinetic.Layer();
var sh_layer = new Kinetic.Layer();
var Left={
light: {
frame: function(){
poly = new Kinetic.Polygon({
points: [70, 0, 0, 22, 0, 672, 70, 720, 70, 710, 6, 667, 6, 29, 70, 10, 70, 0],
stroke: 'white',
strokeWidth: 1
});
// add the shape to the layer
color_layer.add(poly);
stage.add(color_layer);
},
fill: function(color){
poly.setFill(color);
}
},
dark: {
frame: function(){
var poly = new Kinetic.Polygon({
points: [6, 193, 6, 667, 11, 663, 11, 440, 6, 437, 6, 427, 11, 425, 11, 193, 6, 193],
stroke: 'white',
strokeWidth: 1
});
// add the shape to the layer
color_layer.add(poly);
stage.add(color_layer);
},
fill: function(color){
poly.setFill(color);
}
},
}
Left.light.frame();
Left.light.fill('red');
});
What I intend to do is to be able to set the fill color of polygons after I have created them, I have to handle a lot of parts of the image so I use objects to make it simple. Can you point out the problems with my code please? I'm soory I know I'm lame, I just need your help.
EDIT: When I add
Left.dark.frame();
Left.dark.fill('red');
after
Left.light.frame();
Left.light.fill('red');
Left.light.frame() becomes red, but Left.dark.frame() does not