Skip to content

Instantly share code, notes, and snippets.

@gnachman
Created August 8, 2013 02:25
Show Gist options
  • Save gnachman/6180913 to your computer and use it in GitHub Desktop.
Save gnachman/6180913 to your computer and use it in GitHub Desktop.
set rect dirty
- (void)setRectDirtyFromX:(int)fromX Y:(int)fromY toX:(int)toX Y:(int)toY
{
assert(fromX >= 0);
assert(fromX < WIDTH);
assert(toX >= 0);
assert(toX <= WIDTH); // <= because not inclusive of toX.
assert(fromY >= 0);
assert(fromY < HEIGHT);
assert(toY >= 0);
assert(toY < HEIGHT);
assert(fromY <= toY);
if (fromY == toY) {
assert(fromX <= toX);
}
for (int y = fromY; y <= toY; y++) {
int i = fromX + y * WIDTH;
[self setRangeDirty:NSMakeRange(i, toX + y * WIDTH - i)];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment