ios FlowCover效果demo
来源:互联网 发布:淘宝详情手机端加链接 编辑:程序博客网 时间:2024/05/22 10:53
demo功能:flowcover 效果,正反无限循环滚动,每个cover都有单独的倒影
demo说明:项目中FlowCover Classes文件夹是存放核心类。
demo接图:
demo主要代码:绘制部分
- (void)drawTile:(int)index atOffset:(double)off{FlowCoverRecord *fcr = [self getTileAtIndex:index];GLfloat m[16];memset(m,0,sizeof(m));m[10] = 1;m[15] = 1;m[0] = 1;m[5] = 1;double trans = off * SPREADIMAGE;double f = off * FLANKSPREAD;if (f < -FLANKSPREAD) {f = -FLANKSPREAD;} else if (f > FLANKSPREAD) {f = FLANKSPREAD;}m[3] = -f;m[0] = 1-fabs(f);double sc = 0.45 * (1 - fabs(f));trans += f * 1;glPushMatrix();glBindTexture(GL_TEXTURE_2D,fcr.texture);glTranslatef(trans, 0, 0);glScalef(sc,sc,1.0);glMultMatrixf(m);glDrawArrays(GL_TRIANGLE_STRIP,0,4);// reflectglTranslatef(0,-2,0);glScalef(1,-1,1);glColor4f(0.5,0.5,0.5,0.5);glDrawArrays(GL_TRIANGLE_STRIP,0,4);glColor4f(1,1,1,1);glPopMatrix();}- (void)draw{/* *Get the current aspect ratio and initialize the viewport */double aspect = ((double)backingWidth)/backingHeight;glViewport(0,0,backingWidth,backingHeight);glDisable(GL_DEPTH_TEST);// using painters algorithmglClearColor(0,0,0,0);glVertexPointer(3,GL_FLOAT,0,GVertices);glEnableClientState(GL_VERTEX_ARRAY);glTexCoordPointer(2, GL_SHORT, 0, GTextures);glEnableClientState(GL_TEXTURE_COORD_ARRAY);glEnable(GL_TEXTURE_2D);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);glEnable(GL_BLEND);/* *Setup for clear */[EAGLContext setCurrentContext:context]; glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glClear(GL_COLOR_BUFFER_BIT);/* *Set up the basic coordinate system */glMatrixMode(GL_PROJECTION);glLoadIdentity();glScalef(1,aspect,1); glMatrixMode(GL_MODELVIEW);glLoadIdentity();//modify by chenwh 2010-01-06 for round view begin/* *Change from Alesandro Tagliati <alessandro.tagliati@gmail.com>: *We don't need to draw all the tiles, just the visible ones. We guess *there are 6 tiles visible; that can be adjusted by altering the *constant *//*int i,len = [self numTiles];int mid = (int)floor(offset + 0.5);int iStartPos = mid - VISTILES;if (iStartPos<0) {iStartPos=0;}for (i = iStartPos; i < mid; ++i) {[self drawTile:i atOffset:i-offset];}int iEndPos=mid + VISTILES;if (iEndPos >= len) {iEndPos = len-1;}for (i = iEndPos; i >= mid; --i) {[self drawTile:i atOffset:i-offset];}*/int len = [self numTiles];int iStartPos = -VISTILES;int iEndPos = VISTILES;int mid = 0;int pageCount = (int)offset;double moveOffset;if (offset < 0) {moveOffset = offset - ceil(offset);} else {moveOffset = offset - floor(offset);}int index, position;//NSLog(@"offset=%.2f, pageCount=%d, moveOffset=%.2f", offset, pageCount, moveOffset);for (position = iStartPos; position < mid; ++position) {index = (len + position + pageCount) % len;if (index < 0) {index = len + index;}//NSLog(@"index=%d, position=%d", index, position);[self drawTile:index atOffset:position - moveOffset];}for (position = iEndPos; position >= mid; --position) {index = (position + pageCount) % len;if (index < 0) {index = len + index;}//NSLog(@"index=%d, position=%d", index, position);[self drawTile:index atOffset:position - moveOffset];}//modify by chenwh 2010-01-06 for round view endglBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);[context presentRenderbuffer:GL_RENDERBUFFER_OES];}
demo下载地址:http://download.csdn.net/detail/donny_zhang/5544499
- ios FlowCover效果demo
- ios 全景浏览效果demo
- ios 自制放大镜效果demo
- ios 全景浏览效果demo
- iOS侧拉栏抽屉效果Demo
- ios 动画效果实现demo
- iOS侧滑效果Demo
- iPhone FlowCover
- ios 美元飘落效果的demo
- ios 360度旋转效果demo
- iOS 仿照网易侧栏效果demo
- iOS 各种demo链接汇总~模糊效果
- Android的OpenGL FlowCover
- ios 网页中图片点击放大效果demo
- iOS 3D效果的界面选择Demo
- iOS状态栏效果 指示器 开源框架 附有Demo
- iOS TableVew 侧滑效果~ OC语言~demo
- iOS TableVew 侧滑效果~ Swift语言~demo
- inline-block 前世今生
- 读取webconfig里面的appSetting和connectionString
- 【优化】--Squid优化汇总
- 函数调用约定
- iBatis整理——iBatis批处理实现(Spring环境)转载
- ios FlowCover效果demo
- android
- 做项目思考总结若干点
- Pro Android学习笔记(二):开发环境:基础概念、连接真实设备、生命周期
- TCP连接复用
- 节约钱,自己用源代码编译compass.app
- Matlab数据可视化(3):一维数据绘图 I
- 黑马训练营---------------泛型
- CoreText(二) ios字体集合