mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Merge pull request #3 from fsih/moveChangesToSource
Copy changes in selection mode to src files
This commit is contained in:
commit
ff2c9f63c9
3 changed files with 22 additions and 16 deletions
|
@ -13,3 +13,4 @@
|
||||||
- Justin Ridgewell <justinridgewell@gmail.com>
|
- Justin Ridgewell <justinridgewell@gmail.com>
|
||||||
- Andrew Wagenheim <abwagenheim@gmail.com>
|
- Andrew Wagenheim <abwagenheim@gmail.com>
|
||||||
- Scott Kieronski <baroes0239@gmail.com>
|
- Scott Kieronski <baroes0239@gmail.com>
|
||||||
|
- DD Liu <liudi@media.mit.edu>
|
||||||
|
|
|
@ -4408,6 +4408,7 @@ new function() { // Injection scope for hit-test functions shared with project
|
||||||
half = size / 2;
|
half = size / 2;
|
||||||
ctx.strokeStyle = ctx.fillStyle = color
|
ctx.strokeStyle = ctx.fillStyle = color
|
||||||
? color.toCanvasStyle(ctx) : '#009dec';
|
? color.toCanvasStyle(ctx) : '#009dec';
|
||||||
|
ctx.lineWidth=2.5;
|
||||||
if (itemSelected)
|
if (itemSelected)
|
||||||
this._drawSelected(ctx, mx, selectionItems);
|
this._drawSelected(ctx, mx, selectionItems);
|
||||||
if (positionSelected) {
|
if (positionSelected) {
|
||||||
|
|
|
@ -2135,7 +2135,7 @@ new function() { // Scope for drawing
|
||||||
// SegmentPoint objects maybe seem a bit tedious but is worth the benefit in
|
// SegmentPoint objects maybe seem a bit tedious but is worth the benefit in
|
||||||
// performance.
|
// performance.
|
||||||
|
|
||||||
function drawHandles(ctx, segments, matrix, size) {
|
function drawHandles(ctx, segments, matrix, size, isFullySelected) {
|
||||||
var half = size / 2,
|
var half = size / 2,
|
||||||
coords = new Array(6),
|
coords = new Array(6),
|
||||||
pX, pY;
|
pX, pY;
|
||||||
|
@ -2147,10 +2147,12 @@ new function() { // Scope for drawing
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(pX, pY);
|
ctx.moveTo(pX, pY);
|
||||||
ctx.lineTo(hX, hY);
|
ctx.lineTo(hX, hY);
|
||||||
|
ctx.moveTo(hX - half, hY);
|
||||||
|
ctx.lineTo(hX, hY + half);
|
||||||
|
ctx.lineTo(hX + half, hY);
|
||||||
|
ctx.lineTo(hX, hY - half);
|
||||||
|
ctx.closePath();
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(hX, hY, half, 0, Math.PI * 2, true);
|
|
||||||
ctx.fill();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2160,20 +2162,22 @@ new function() { // Scope for drawing
|
||||||
segment._transformCoordinates(matrix, coords);
|
segment._transformCoordinates(matrix, coords);
|
||||||
pX = coords[0];
|
pX = coords[0];
|
||||||
pY = coords[1];
|
pY = coords[1];
|
||||||
if (selection & /*#=*/SegmentSelection.HANDLE_IN)
|
// Don't draw handles when the shape is fully selected.
|
||||||
drawHandle(2);
|
if (selection & /*#=*/SegmentSelection.HANDLE_IN && !isFullySelected)
|
||||||
if (selection & /*#=*/SegmentSelection.HANDLE_OUT)
|
drawHandle(/*#=*/SegmentSelection.HANDLE_IN);
|
||||||
drawHandle(4);
|
if (selection & /*#=*/SegmentSelection.HANDLE_OUT && !isFullySelected)
|
||||||
// Draw a rectangle at segment.point:
|
drawHandle(/*#=*/SegmentSelection.HANDLE_OUT);
|
||||||
ctx.fillRect(pX - half, pY - half, size, size);
|
// Draw a circle at segment.point:
|
||||||
// If the point is not selected, draw a white square that is 1 px
|
ctx.beginPath();
|
||||||
// smaller on all sides:
|
ctx.arc(pX, pY, half, 0, Math.PI * 2, true);
|
||||||
|
ctx.stroke();
|
||||||
|
var fillStyle = ctx.fillStyle;
|
||||||
|
// If the point is not selected, fill the point with semitransparent white:
|
||||||
if (!(selection & /*#=*/SegmentSelection.POINT)) {
|
if (!(selection & /*#=*/SegmentSelection.POINT)) {
|
||||||
var fillStyle = ctx.fillStyle;
|
ctx.fillStyle = 'rgba(255, 255, 255, 0.5)';
|
||||||
ctx.fillStyle = '#ffffff';
|
|
||||||
ctx.fillRect(pX - half + 1, pY - half + 1, size - 2, size - 2);
|
|
||||||
ctx.fillStyle = fillStyle;
|
|
||||||
}
|
}
|
||||||
|
ctx.fill();
|
||||||
|
ctx.fillStyle = fillStyle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue