Die Box enthält NUMBER Punkte. Indem du ihre Größe veränderst kannst du alle Teiler finden.
init({ range: [[-3, NUMBER + 3], [-NUMBER - 3, 3]], scale: [20, 20] });
addMouseLayer();
graph.width = NUMBER;
graph.height = 1;
graph.set = bogusShape;
graph.handle = bogusShape;
graph.topLabel = bogusShape;
graph.leftLabel = bogusShape;
graph.redraw = function() {
graph.set.remove();
graph.topLabel.remove();
graph.leftLabel.remove();
graph.height = ceil(NUMBER / graph.width);
init({ range: [[-3, graph.width + 3], [-graph.height - 2, 3]], scale: [20, 20] });
graph.set = raphael.set();
graph.set.push(path([
[-1, 1],
[graph.width, 1],
[graph.width, -graph.height],
[-1, -graph.height],
[-1, 1], [1, 1]],{ stroke: BLUE, opacity: 1.0 }));
_(NUMBER).times(function(i) {
graph.set.push(circle([i % graph.width, -floor(i / graph.width)], 0.25,
{ stroke: BLUE, fill: BLUE, opacity: 0.6 }));
});
graph.handle.translate(
graph.width * 20 - graph.handle[0].attr("translation").x,
graph.height * 10 - graph.handle[0].attr("translation").y);
graph.topLabel = label([graph.width / 2 - 0.5, 1], graph.width, "above");
graph.leftLabel = label([-1, -graph.height / 2 + 0.5], graph.height, "left");
};
graph.dragHandle = addMovablePoint({
coord: [graph.width, -graph.height / 2 + 0.5],
constraints: {
constrainY: true
},
snapX: 1,
onMove: function(x, y) {
graph.width = min(max(x, 1), NUMBER);
graph.redraw();
return [graph.width, -graph.height / 2 + 0.5];
}
});
graph.handle = raphael.set();
graph.handle.push(line(
[-0.12, 0],
[-0.12, 1], { stroke: BLUE, opacity: 1.0 }));
graph.handle.push(line(
[0.12, 0],
[0.12, 1], { stroke: BLUE, opacity: 1.0 }));
graph.dragHandle.visibleShape.remove();
graph.dragHandle.mouseTarget.attr({ scale: 2.0 });
$(graph.dragHandle.mouseTarget[0]).bind("vmouseover", function(event) {
graph.handle.animate({ scale: 1.5, stroke: BLUE }, 50);
});
$(graph.dragHandle.mouseTarget[0]).bind("vmouseout", function(event) {
graph.handle.animate({ scale: 1.0, stroke: BLUE }, 50);
});
graph.redraw();