Improve examples.

This commit is contained in:
Jonathan Puckey 2013-03-09 16:28:53 +01:00
parent ace2e3e13b
commit c9e95d2c01
3 changed files with 20 additions and 20 deletions

View file

@ -16,12 +16,6 @@
checkValues();
project.currentStyle = {
strokeColor: 'black',
strokeWidth: 5,
strokeCap: 'round'
};
/////////////////////////////////////////////////////////////////////
// Mouse handling
@ -34,17 +28,17 @@
var path;
function onMouseDown(event) {
path = new Path();
path.segments = [event.point, event.point];
path = new Path({
segments: [event.point, event.point],
strokeColor: 'black',
strokeWidth: 5,
strokeCap: 'round'
});
prevPoint = path.firstSegment.point;
curPoint = path.lastSegment.point;
curHandleSeg = null;
}
function onMouseUp(event) {
// path.pointsToCurves(0, 0, 1, 0.001);
}
var curPoint, prevPoint, curHandleSeg;
function onMouseDrag(event) {
var point = event.point;

View file

@ -15,8 +15,12 @@
var delta = event.point - event.downPoint;
var radius = delta.length;
var points = 5 + Math.round(radius / 50);
var position = event.downPoint;
var path = new Path.Star(position, points, radius / 2, radius);
var path = new Path.Star({
center: event.downPoint,
numPoints: points,
radius1: radius / 2,
radius2: radius
});
path.rotate(delta.angle);
// Remove the path automatically before the next mouse drag
// event:

View file

@ -23,8 +23,9 @@
var path;
function onMouseDown(event) {
path = new Path();
path.strokeColor = '#000000';
path = new Path({
strokeColor: '#000000'
});
}
var mul = 1;
@ -34,10 +35,11 @@
if (!values.mouseOffset)
step.length = values.offset;
var segment = new Segment(event.point + step);
segment.handleIn = -event.delta * values.curviness;
segment.handleOut = event.delta * values.curviness;
path.add(segment);
path.add({
point: event.point + step,
handleIn: -event.delta * values.curviness,
handleOut: event.delta * values.curviness
});
mul *= -1;
}
</script>