improve code readability
This commit is contained in:
parent
1094e5214e
commit
2eb4c78794
4 changed files with 25 additions and 12 deletions
|
@ -5,7 +5,10 @@
|
|||
#
|
||||
var Group = {
|
||||
new: func(ghost) {
|
||||
return { parents: [Group, Element.new(ghost)] };
|
||||
var obj = {
|
||||
parents: [Group, Element.new(ghost)],
|
||||
};
|
||||
return obj;
|
||||
},
|
||||
|
||||
# Create a child of given type with specified id.
|
||||
|
@ -94,8 +97,9 @@ var Group = {
|
|||
if (typeof(first) == "vector")
|
||||
color = first;
|
||||
}
|
||||
foreach(var c; children)
|
||||
c.setColor(color);
|
||||
foreach(var c; children) {
|
||||
c.setColor(color);
|
||||
}
|
||||
},
|
||||
|
||||
# Get first child with given id (breadth-first search)
|
||||
|
@ -129,13 +133,15 @@ var Group = {
|
|||
|
||||
# Create element from existing node
|
||||
_wrapElement: func(node) {
|
||||
return me._element_factories[node.getName()](me._getChild(node._g));
|
||||
var factory = me._getFactory(node.getName());
|
||||
return factory(me._getChild(node._g));
|
||||
},
|
||||
|
||||
_getFactory: func(type) {
|
||||
var factory = me._element_factories[type];
|
||||
if (factory == nil)
|
||||
debug.dump("canvas.Group.createChild(): unknown type ("~type~")");
|
||||
if (factory == nil) {
|
||||
logprint(DEV_ALERT, "canvas.Group.createChild(): unknown type ("~type~")");
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
#
|
||||
var Image = {
|
||||
new: func(ghost) {
|
||||
return {parents: [Image, Element.new(ghost)]};
|
||||
var obj = {
|
||||
parents: [Image, Element.new(ghost)],
|
||||
};
|
||||
return obj;
|
||||
},
|
||||
|
||||
# Set image file to be used
|
||||
|
|
|
@ -8,13 +8,16 @@
|
|||
var Map = {
|
||||
df_controller: nil,
|
||||
new: func(ghost) {
|
||||
return { parents: [Map, Group.new(ghost)], layers:{},
|
||||
controller:nil }
|
||||
.setController();
|
||||
var obj = {
|
||||
parents: [Map, Group.new(ghost)],
|
||||
layers: {},
|
||||
controller: nil,
|
||||
};
|
||||
return obj.setController();
|
||||
},
|
||||
|
||||
del: func() {
|
||||
#print("canvas.Map.del()");
|
||||
logprint(_API_dbg_level, "canvas.Map.del()");
|
||||
if (me.controller != nil)
|
||||
me.controller.del(me);
|
||||
foreach (var k; keys(me.layers)) {
|
||||
|
|
|
@ -63,13 +63,14 @@ var Path = {
|
|||
#
|
||||
new: func(ghost)
|
||||
{
|
||||
return {
|
||||
var obj = {
|
||||
parents: [Path, Element.new(ghost)],
|
||||
_first_cmd: 0,
|
||||
_first_coord: 0,
|
||||
_last_cmd: -1,
|
||||
_last_coord: -1
|
||||
};
|
||||
return obj;
|
||||
},
|
||||
|
||||
# Remove all existing path data
|
||||
|
|
Loading…
Add table
Reference in a new issue