mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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>
|
||||
- Andrew Wagenheim <abwagenheim@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;
|
||||
ctx.strokeStyle = ctx.fillStyle = color
|
||||
? color.toCanvasStyle(ctx) : '#009dec';
|
||||
ctx.lineWidth=2.5;
|
||||
if (itemSelected)
|
||||
this._drawSelected(ctx, mx, selectionItems);
|
||||
if (positionSelected) {
|
||||
|
|
|
@ -2135,7 +2135,7 @@ new function() { // Scope for drawing
|
|||
// SegmentPoint objects maybe seem a bit tedious but is worth the benefit in
|
||||
// performance.
|
||||
|
||||
function drawHandles(ctx, segments, matrix, size) {
|
||||
function drawHandles(ctx, segments, matrix, size, isFullySelected) {
|
||||
var half = size / 2,
|
||||
coords = new Array(6),
|
||||
pX, pY;
|
||||
|
@ -2147,10 +2147,12 @@ new function() { // Scope for drawing
|
|||
ctx.beginPath();
|
||||
ctx.moveTo(pX, pY);
|
||||
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.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);
|
||||
pX = coords[0];
|
||||
pY = coords[1];
|
||||
if (selection & /*#=*/SegmentSelection.HANDLE_IN)
|
||||
drawHandle(2);
|
||||
if (selection & /*#=*/SegmentSelection.HANDLE_OUT)
|
||||
drawHandle(4);
|
||||
// Draw a rectangle at segment.point:
|
||||
ctx.fillRect(pX - half, pY - half, size, size);
|
||||
// If the point is not selected, draw a white square that is 1 px
|
||||
// smaller on all sides:
|
||||
// Don't draw handles when the shape is fully selected.
|
||||
if (selection & /*#=*/SegmentSelection.HANDLE_IN && !isFullySelected)
|
||||
drawHandle(/*#=*/SegmentSelection.HANDLE_IN);
|
||||
if (selection & /*#=*/SegmentSelection.HANDLE_OUT && !isFullySelected)
|
||||
drawHandle(/*#=*/SegmentSelection.HANDLE_OUT);
|
||||
// Draw a circle at segment.point:
|
||||
ctx.beginPath();
|
||||
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)) {
|
||||
var fillStyle = ctx.fillStyle;
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.fillRect(pX - half + 1, pY - half + 1, size - 2, size - 2);
|
||||
ctx.fillStyle = fillStyle;
|
||||
ctx.fillStyle = 'rgba(255, 255, 255, 0.5)';
|
||||
}
|
||||
ctx.fill();
|
||||
ctx.fillStyle = fillStyle;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue