Lua中利用元表实现类和多态.docx
- 文档编号:12087834
- 上传时间:2023-04-17
- 格式:DOCX
- 页数:41
- 大小:25.52KB
Lua中利用元表实现类和多态.docx
《Lua中利用元表实现类和多态.docx》由会员分享,可在线阅读,更多相关《Lua中利用元表实现类和多态.docx(41页珍藏版)》请在冰豆网上搜索。
Lua中利用元表实现类和多态
Lua中利用元表实现类和多态,MD5Util、SHA1Util、HmacMD5Util、HmacSHAUtilmemcache通用类包括hash分配,memcache通用类包括一致hash分配
MVVM思路选择框常用的逻辑实现,Mybatis根据经纬度获取附近的人,MySQL主键与索引的联系与区别,mysql创建触发器的详细过程,删除表中多个字段分组后的重复数据
[代码][Java]代码
importjava.nio.ByteBuffer;
importjava.nio.ByteOrder;
importjava.nio.FloatBuffer;
importjava.nio.IntBuffer;
importjavax.microedition.khronos.opengles.GL10;
//jquery实现倒计时的插件
//jquery实现复制功能
publicclassStars{
finalfloatUNIT_SIZE=15.0f;//天球半径
privateFloatBuffermVertexBuffer;//顶点坐标数据缓冲
privateIntBuffermColorBuffer;//顶点着色数据缓冲
intvCount=0;//星星数量
floatyAngle;//天球延Y轴旋转的角度
intxOffset;//x平移量
intzOffset;//z平移量
floatscale;//星星尺寸
publicStars(intxOffset,intzOffset,floatscale,floatyAngle,intvCount)
{
this.xOffset=xOffset;
this.zOffset=zOffset;
this.yAngle=yAngle;
this.scale=scale;
this.vCount=vCount;
//顶点坐标数据的初始化================begin=======================================
floatvertices[]=newfloat[vCount*3];//每一个点用XYZ坐标三个数表示
for(inti=0;i { //随机产生每个星星的xyz坐标 doubleangleTempJD=Math.PI*2*Math.random();//经度上0~360度内随机度数 doubleangleTempWD=Math.PI/2*Math.random();//纬度上0~90度内随机度数 vertices[i*3]=(float)(UNIT_SIZE*Math.cos(angleTempWD)*Math.sin(angleTempJD));//通过球公式计算球面上对应经纬度上的点的坐标 vertices[i*3+1]=(float)(UNIT_SIZE*Math.sin(angleTempWD)); vertices[i*3+2]=(float)(UNIT_SIZE*Math.cos(angleTempWD)*Math.cos(angleTempJD)); } //创建顶点坐标数据缓冲 //vertices.length*4是因为一个Float四个字节 ByteBuffervbb=ByteBuffer.allocateDirect(vertices.length*4); vbb.order(ByteOrder.nativeOrder());//设置字节顺序 mVertexBuffer=vbb.asFloatBuffer();//转换为int型缓冲 mVertexBuffer.put(vertices);//向缓冲区中放入顶点坐标数据 mVertexBuffer.position(0);//设置缓冲区起始位置 //特别提示: 由于不同平台字节顺序不同数据单元不是字节的一定要经过ByteBuffer //转换,关键是要通过ByteOrder设置nativeOrder(),否则有可能会出问题 //顶点坐标数据的初始化================end============================ //顶点着色数据的初始化================begin============================ finalintone=65535; intcolors[]=newint[vCount*4];//顶点颜色值数组,每个顶点4个色彩值RGBA for(inti=0;i { colors[i*4]=one; colors[i*4+1]=one; colors[i*4+2]=one; colors[i*4+3]=0; } //创建顶点着色数据缓冲 //vertices.length*4是因为一个int型整数四个字节 ByteBuffercbb=ByteBuffer.allocateDirect(colors.length*4); cbb.order(ByteOrder.nativeOrder());//设置字节顺序 mColorBuffer=cbb.asIntBuffer();//转换为int型缓冲 mColorBuffer.put(colors);//向缓冲区中放入顶点着色数据 mColorBuffer.position(0);//设置缓冲区起始位置 //特别提示: 由于不同平台字节顺序不同数据单元不是字节的一定要经过ByteBuffer //转换,关键是要通过ByteOrder设置nativeOrder(),否则有可能会出问题 //顶点着色数据的初始化================end============================ } publicvoiddrawSelf(GL10gl) { gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);//启用顶点坐标数组 gl.glEnableClientState(GL10.GL_COLOR_ARRAY);//启用顶点颜色数组 gl.glDisable(GL10.GL_LIGHTING);//不允许光照 gl.glPointSize(scale);//设置星星尺寸 gl.glPushMatrix();//保护变换矩阵 gl.glTranslatef(xOffset*UNIT_SIZE,0,0);//x向偏移 gl.glTranslatef(0,0,zOffset*UNIT_SIZE);//y向偏移 gl.glRotatef(yAngle,0,1,0);//y轴旋转 //为画笔指定顶点坐标数据 gl.glVertexPointer ( 3,//每个顶点的坐标数量为3xyz GL10.GL_FLOAT,//顶点坐标值的类型为GL_FIXED 0,//连续顶点坐标数据之间的间隔 mVertexBuffer//顶点坐标数据 ); //为画笔指定顶点着色数据 gl.glColorPointer ( 4,//设置颜色的组成成分,必须为4—RGBA GL10.GL_FIXED,//顶点颜色值的类型为GL_FIXED 0,//连续顶点着色数据之间的间隔 mColorBuffer//顶点着色数据 ); //绘制点 gl.glDrawArrays ( GL10.GL_POINTS,//以点方式填充 0,//开始点编号 vCount//顶点的数量 ); gl.glPopMatrix();//恢复变换矩阵 gl.glPointSize (1);//恢复像素尺寸 gl.glEnable(GL10.GL_LIGHTING);//允许光照 } } [代码][Java]代码 publicclassAnimActivityextendsActivity{ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(newPlasmaView(this)); } } classPlasmaViewextendsViewimplementsView.OnTouchListener{ privateBitmapmBitmap; longtime; longfps; publicPlasmaView(Contextcontext){ super(context); Bitmapbmp=BitmapFactory.decodeResource(this.getResources(),R.drawable.mm); mBitmap=Bitmap.createBitmap(bgetWidth(),bgetHeight(),Bitmap.Config.RGB_565); AnimRender.setBitmap(bmp); this.setOnTouchListener(this); } @Override protectedvoidonDraw(Canvascanvas){ longct=System.currentTimeMillis(); if(ct-time>1000){ Log.v("Fps: "+String.valueOf(fps)); time=ct; fps=0; } //fps++; fps+=20; AnimRender.render(mBitmap); canvas.drawBitmap(mBitmap,0,0,null); postInvalidate(); } @Override publicbooleanonTouch(Viewv,MotionEventevent){ //TODOAuto-generatedmethodstub AnimRender.drop((int)event.getX(),(int)event.getY(),1200); returnfalse; } } classAnimRender{ publicstaticnativevoidsetBitmap(Bitmapsrc); publicstaticnativevoidrender(Bitmapdst); publicstaticnativevoiddrop(intx,inty,intheight); static{ System.loadLibrary("plasma"); } } [文件]water_android.zip ~ 174KB (2948) 文件不存在或者代码语言不存在 [代码][CSS]代码 /*导航CSS*/ nav{margin: auto;width: 960px;text-align: center;margin-bottom: 30px;} navul{list-style: none;white-space: nowrap;} navulli{float: left;} navullia{border-bottom: 1pxsolid#0099cc;margin-left: 30px;} /*=Navigation*/ #menu-navi{height: 40px;line-height: 40px;font-size: 16px;clear: both;} #menu-navia{-webkit-transition: background0.2sease-in-out;-moz-transition: background0.2sease-in-out;-o-transition: background0.2sease-in-out;-ms-transition: background0.2sease-in-out;transition: background0.2sease-in-out;} /***ESSENTIALNavigationStyle***/ .sf-menu,.sf-menu*{margin: 0;padding: 0;list-style: none;} .sf-menu{line-height: 1.0} .sf-menuul{position: absolute;top: -999em;width: 10em;/*leftoffsetofsubmenusneedtomatch(seebelow)*/} .sf-menuulli{width: 100%} .sf-menuli: hover{visibility: inherit;/*fixesIE7'stickybug'*/} .sf-menuli{float: left;position: relative;} .sf-menua{display: block;position: relative;} .sf-menuli: hoverul, .sf-menuli.sfHoverul{left: 0;top: 40px;/*matchtopullistitemheight*/z-index: 99;background: #0099CC;} ul.sf-menuli: hoverliul, ul.sf-menuli.sfHoverliul{top: -999em} ul.sf-menulili: hoverul, ul.sf-menulili.sfHoverul{left: 10em;/*matchulwidth*/top: 0;} ul.sf-menulili: hoverliul, ul.sf-menulili.sfHoverliul{top: -999em} ul.sf-menulilili: hoverul, ul.sf-menulilili.sfHoverul{left: 10em;/*matchulwidth*/top: 0;} /***navigationskin***/ .sf-menu{float: left;margin-bottom: 1em;} .sf-menua{color: #666;padding: 015px;height: 40px;line-height: 40px;text-decoration: none;text-transform: uppercase;} .sf-menua: focus, .sf-menua: hover{color: #FFF;background: #03749D;} li.sfHover{color: #fff;} .sf-menulili{text-transform: none;} .sf-menulilili{background: #0099cc;} .sf-menuula{color: #fff;padding: 01.2em;height: 35px;line-height: 35px;} [代码][HTML]代码
模版 插件
支付 关于
[图片]截图
[文件]whois.php ~ 2KB (93)
php
functionwhois_query($domain){
//fixthedomainname:
$domain=strtolower(trim($domain));
$domain=preg_replace('/^http:
\/\//i','',$domain);
$domain=preg_replace('/^www\./i','',$domain);
$domain=explode('/',$domain);
$domain=trim($domain[0]);
//splittheTLDfromdomainname
$_domain=explode('.',$domain);
$lst=count($_domain)-1;
$ext=$_domain[$lst];
//Youfindresourcesandlists
//liketheseonwikipedia:
//
//de.wikipedia.org/wiki/Whois
//
$servers=array(
"biz"=>"whois.neulevel.biz",
"com"=>"whois.internic",
"us"=>"whois.nic.us",
"coop"=>"whois.nic.coop",
"info"=>"whois.nic.info",
"name"=>"whois.nic.name",
"net"=>"whois.internic",
"gov"=>"whois.nic.gov",
"edu"=>"whois.internic",
"mil"=>"rs.internic",
"int"=>"whois.iana.org",
"ac"=>"whois.nic.ac",
"ae"=>"whois.uaenic.ae",
"at"=>"whois.ripe",
"au"=>"whois.aunic",
"be"=>"whois.dns.be",
"bg"=>"whois.ripe",
"br"=>"whois.registro.br",
"bz"=>"whois.belizenic.bz",
"ca"=>"whois.cira.ca",
"cc"=>"whois.nic.cc",
"ch"=>"whois.nic.ch",
"cl"=>"whois.nic.cl",
"cn"=>"whoisnic",
"cz"=>"whois.nic.cz",
"de"=>"whois.nic.de",
"fr"=>"whois.nic.fr",
"hu"=>"whois.nic.hu",
"ie"=>"whois.domainregistry.ie",
"il"=>"whois.isoc.org.il",
"in"=>"whois.ncst.ernet.in",
"ir"=>"whois.nic.ir",
"mc"=>"whois.ripe",
"to"=>"whois.tonic.to",
"tv"=>"whois.tv",
"ru"=>"whois.ripn",
"org"=>"whois.pir.org",
"aero"=>"whois.information.aero",
"nl"=>"whois.domain-registry.nl"
);
if(!
isset($servers[$ext])){
die('Error:
Nomatchingnicserverfound!
');
}
$nic_server=$servers[$ext];
$output='';
//connecttowhoisserver:
if($conn=fsockopen($nic_server,43)){
fputs($conn,$domain."\r\n");
while(!
feof($conn)){
$output.=fgets($conn,128);
}
fclose($conn);
}
else{die('Error:
Couldnotconnectto'.$nic_server.'!
');}
returnnl2br($output);
}
$domain=$_GET["d"]?
$_GET["d"]:
"bitefu";
echowhois_query($domain);
?
>
[图片]QQ截图20120208163933.png
[文件]whois.php ~ 2KB (47)
php
functionwhois_query($domain){
//fixthedomainname:
$domain=parse_(strtolower(trim($domain)));
$domain=$domain['host']?
$domain['host']:
$domain['path'];
$domain=preg_replace('/^www\./i','',$domain);
echo$domain;
//splittheTLDfromdomainname
$_domain=explode('.',$domain);
$lst=count($_domain)-1;
$ext=$_domain[$lst];
//Youfindresourcesandlists
/
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Lua 利用 实现