com.wallstop-studios.unity-helpers 2.0.0-rc74.7 → 2.0.0-rc74.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/Sprites/SpriteCropper.cs +40 -21
- package/package.json +2 -1
|
@@ -352,25 +352,32 @@
|
|
|
352
352
|
}
|
|
353
353
|
);
|
|
354
354
|
|
|
355
|
-
int
|
|
356
|
-
int
|
|
357
|
-
|
|
355
|
+
int origMinX = minX;
|
|
356
|
+
int origMinY = minY;
|
|
357
|
+
int origMaxX = maxX;
|
|
358
|
+
int origMaxY = maxY;
|
|
359
|
+
|
|
360
|
+
int visibleMinX = minX;
|
|
361
|
+
int visibleMinY = minY;
|
|
362
|
+
int visibleMaxX = maxX;
|
|
363
|
+
int visibleMaxY = maxY;
|
|
364
|
+
|
|
365
|
+
if (hasVisible)
|
|
358
366
|
{
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
367
|
+
visibleMinX -= _leftPadding;
|
|
368
|
+
visibleMinY -= _bottomPadding;
|
|
369
|
+
visibleMaxX += _rightPadding;
|
|
370
|
+
visibleMaxY += _topPadding;
|
|
363
371
|
}
|
|
364
372
|
else
|
|
365
373
|
{
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
maxX += _rightPadding;
|
|
369
|
-
maxY += _topPadding;
|
|
370
|
-
cropWidth = maxX - minX + 1;
|
|
371
|
-
cropHeight = maxY - minY + 1;
|
|
374
|
+
visibleMinX = visibleMinY = 0;
|
|
375
|
+
visibleMaxX = visibleMaxY = 0;
|
|
372
376
|
}
|
|
373
377
|
|
|
378
|
+
int cropWidth = visibleMaxX - visibleMinX + 1;
|
|
379
|
+
int cropHeight = visibleMaxY - visibleMinY + 1;
|
|
380
|
+
|
|
374
381
|
if (_onlyNecessary && (!hasVisible || (cropWidth == width && cropHeight == height)))
|
|
375
382
|
{
|
|
376
383
|
return null;
|
|
@@ -384,21 +391,33 @@
|
|
|
384
391
|
cropHeight,
|
|
385
392
|
y =>
|
|
386
393
|
{
|
|
387
|
-
int
|
|
388
|
-
int destYOffset = y * cropWidth;
|
|
394
|
+
int destRow = y * cropWidth;
|
|
389
395
|
for (int x = 0; x < cropWidth; ++x)
|
|
390
396
|
{
|
|
391
|
-
int
|
|
392
|
-
|
|
393
|
-
|
|
397
|
+
int srcX = visibleMinX + x;
|
|
398
|
+
int srcY = visibleMinY + y;
|
|
399
|
+
|
|
400
|
+
bool insideOriginal =
|
|
401
|
+
srcX >= origMinX
|
|
402
|
+
&& srcX <= origMaxX
|
|
403
|
+
&& srcY >= origMinY
|
|
404
|
+
&& srcY <= origMaxY;
|
|
405
|
+
|
|
406
|
+
if (insideOriginal)
|
|
394
407
|
{
|
|
395
|
-
|
|
408
|
+
if (0 <= srcX && srcX < width && 0 <= srcY && srcY < height)
|
|
409
|
+
{
|
|
410
|
+
croppedPixels[destRow + x] = pixels[srcY * width + srcX];
|
|
411
|
+
}
|
|
412
|
+
else
|
|
413
|
+
{
|
|
414
|
+
croppedPixels[destRow + x] = Color.clear;
|
|
415
|
+
}
|
|
396
416
|
}
|
|
397
417
|
else
|
|
398
418
|
{
|
|
399
|
-
|
|
419
|
+
croppedPixels[destRow + x] = Color.clear;
|
|
400
420
|
}
|
|
401
|
-
croppedPixels[destYOffset + x] = sourcePixel;
|
|
402
421
|
}
|
|
403
422
|
}
|
|
404
423
|
);
|
package/package.json
CHANGED