Last active
August 29, 2015 13:58
-
-
Save nicloay/10406080 to your computer and use it in GitHub Desktop.
this code is evil, but works fas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static PointsRegion __newPointsRegion; | |
static int __yy,__xx; | |
static bool __prevPixelSeed; | |
private static void scanUpBelowPixelsRegionForward (ref int xLeft, ref int xRight, ref int baseY, ref int maxY, ref PointsRegion pointsRegion, | |
ref Color32[,] colors, ref bool[,] persistentBorder, ref Color32 seedColor, ref Queue queue, bool[,] resultRegion) { | |
__newPointsRegion = new PointsRegion (); | |
__yy = baseY + pointsRegion.direction; | |
if (__yy >= 0 && __yy < maxY) { | |
__prevPixelSeed = false; | |
for (__xx = xLeft; __xx<=xRight; __xx++) { | |
if (resultRegion [__xx, __yy] != true | |
&& (!persistentBorder [__xx, __yy] | |
&& ((colors [__xx, __yy].a < 255) | |
|| ( seedColor.r == colors[__xx, __yy].r | |
&& seedColor.g == colors[__xx, __yy].g | |
&& seedColor.b == colors[__xx, __yy].b | |
&& seedColor.a == colors[__xx, __yy].a))) | |
) { | |
if (!__prevPixelSeed) { | |
__newPointsRegion.direction = pointsRegion.direction ; | |
__newPointsRegion.y = __yy ; | |
__newPointsRegion.xLeft = __xx ; | |
__prevPixelSeed = true ; | |
} | |
} else { | |
if (__prevPixelSeed) { | |
__newPointsRegion.xRight = __xx-1; | |
__prevPixelSeed = false; | |
queue.Enqueue (__newPointsRegion); | |
} | |
} | |
} | |
if(__prevPixelSeed){ | |
__newPointsRegion.xRight = xRight; | |
queue.Enqueue(__newPointsRegion); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment