Graphics Reference
In-Depth Information
- ( void )viewDidLayoutSubviews
{
[ self updateLayers ];
}
- ( void )scrollViewDidScroll:( UIScrollView *)scrollView
{
[ self updateLayers ];
}
- ( void )updateLayers
{
//calculate clipping bounds
CGRect bounds = self . scrollView . bounds ;
bounds. origin = self . scrollView . contentOffset ;
bounds = CGRectInset (bounds, - SIZE / 2 , - SIZE / 2 );
//create layers
NSMutableArray *visibleLayers = [ NSMutableArray array ];
for ( int z = DEPTH - 1 ; z >= 0 ; z--)
{
//increase bounds size to compensate for perspective
CGRect adjusted = bounds;
adjusted. size . width /= PERSPECTIVE (z* SPACING );
adjusted. size . height /= PERSPECTIVE (z* SPACING );
adjusted. origin . x -= (adjusted. size . width - bounds. size . width ) / 2 ;
adjusted. origin . y -= (adjusted. size . height - bounds. size . height ) / 2 ;
for ( int y = 0 ; y < HEIGHT ; y++)
{
//check if vertically outside visible rect
if (y* SPACING < adjusted. origin . y ||
y* SPACING >= adjusted. origin . y + adjusted. size . height )
{
continue ;
}
for ( int x = 0 ; x < WIDTH ; x++)
{
//check if horizontally outside visible rect
if (x* SPACING < adjusted. origin . x ||
x* SPACING >= adjusted. origin . x + adjusted. size . width )
{
continue ;
}
Search WWH ::




Custom Search