Pablo

map(fn, [context])

Iterates over each element in the collection passing it to a callback function returning a new collection comprising of elements returned from the callback.

The callback is passed two arguments: the element and its index in the collection.

The context of the callback function is that of the collection unless specified otherwise as the context argument.

var col = Pablo();

col.push(Pablo.circle({cx:20,  cy: 20, r: 20, fill: 'red'}));
col.push(Pablo.circle({cx:60,  cy: 20, r: 20, fill: 'red'}));
col.push(Pablo.circle({cx:100, cy: 20, r: 20, fill: 'blue'}));
col.push(Pablo.circle({cx:140, cy: 20, r: 20, fill: 'red'}));

// Use map to filter out blue shapes
col = col.map(function (elem, i) {
        if (Pablo(elem).attr('fill') === 'red') {
          return elem;
        }
      });

Pablo(demoElement).svg({height:60})
                  .append(col);
Painting is just another way of keeping a diary.
Pablo Picasso