Pablo

select(filter, [context])

Returns a Pablo wrapped element(s) which matches the passed selector.

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

var shapes = Pablo(),
    chosen;

shapes.push(Pablo.circle({r: 20, rx: 30, ry:30}));
shapes.push(Pablo.rect({width: 30, height: 30}));
shapes.push(Pablo.circle({r: 15, rx: 20, ry:26}));
shapes.push(Pablo.a());

// Draw only the rect
chosen = shapes.select('rect');

Pablo(demoElement).svg({height:60})
                  .append(chosen);

select(fn, [context])

Passes each element in the collection through an iterator function, returning a new collection of all the elements for which the iterator returns true. The iterator is passed two arguments: the element and its index.

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

Note: This method is analgous to Array.filter and Underscore.select. It is not called .filter() because that method already exists - it creates an SVG <filter> element.

var col           = Pablo(),
    consideredBig = 30, // try changing this
    filtered;

col.push(Pablo.circle({r: 40, cx: 40,  cy: 70, fill: 'red'}));
col.push(Pablo.circle({r: 20, cx: 100, cy: 70, fill: 'green'}));
col.push(Pablo.circle({r: 50, cx: 170, cy: 70, fill: 'blue'}));
col.push(Pablo.circle({r: 60, cx: 280, cy: 70, fill: 'cyan'}));
col.push(Pablo.circle({r: 30, cx: 370, cy: 70, fill: 'purple'}));

// Select only the big circles
filtered = col.select(function (elem) {
  if (Pablo(elem).attr('r') >= consideredBig){
    return true;
  }
});

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