这个是烟花代码!怎么改好看点?
请看以下两种:
1
单击后字线如放烟花
!--第一步:把如下代码加入head区域中--
SCRIPT LANGUAGE="JavaScript1.2"
!-- Begin
var ver = navigator.appVersion;
var dom = document.getElementById ? 1 : 0;
var ie5 = (ver.indexOf("MSIE 5") -1 dom) ? 1 : 0;
var n = (document.layers);
var ie = (document.all);
var sparksAflyin = 0;
var totalSparks = 0;
var sparksOn = 1;
function initMouseEvents() {
document.onmousedown = mouseDown;
if (n) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
}
function mouseDown(e) {
if (sparksOn) {
var mousex = (n) ? e.pageX : event.x+document.body.scrollLeft;
var mousey = (n) ? e.pageY : event.y+document.body.scrollTop;
if (!sparksAflyin) {
for (var k = 0; k = 9; k++)
eval(’SHOW("sDiv’+k+’")’);
sparksAflyin = 1;
totalSparks = 0;
for(i = 0;i = 9; i++)
eval(’moveTo(’+i+’,0,’+mousex+’,’+mousey+’)’);
}
}
}
function moveTo(i,j, mousex, mousey){
if (j eval(’anim_’+i+’_x.length’) ){
var tempx = eval(’anim_’+i+’_x[j]+mousex’);
var tempy = eval(’anim_’+i+’_y[j]+mousey’);
if (ie) {
if(tempy+30 (document.body.offsetHeight+document.body.scrollTop))
tempy = document.body.offsetHeight+document.body.scrollTop-30;
if(tempx+30 (document.body.offsetWidth+document.body.scrollLeft))
tempx = document.body.offsetWidth+document.body.scrollLeft-30;
eval(’document.all.sDiv’+i+’.style.left = tempx;’);
eval(’document.all.sDiv’+i+’.style.top = tempy;’);
}
if (n) {
eval(’document.layers.sDiv’+i+’.left = tempx;’);
eval(’document.layers.sDiv’+i+’.top = tempy;’);
}
j++;
// timeout: 50 = fireworks speed, larger number = slower speed
setTimeout("moveTo("+i+","+j+","+mousex+","+mousey+")",50)
}
else {
eval(’HIDE("sDiv’+i+’")’);
totalSparks++;
}
if (totalSparks == 10) {
sparksAflyin = 0;
totalSparks = 0;
}
}
function SHOW(divName){
if (document.all)
eval(’document.all.’+divName+’.style.visibility = "visible";’);
else if (document.layers)
eval(’document.layers["’+divName+’"].visibility = "visible";’);
}
function HIDE(divName){
if (document.all)
eval(’document.all.’+divName+’.style.visibility = "hidden";’);
else if (document.layers)
eval(’document.layers["’+divName+’"].visibility = "hide";’);
}
anim_0_x=new Array(20,20,10,0,0,0,0,0,0,0,0,0);
anim_0_y=new Array(-20,-40,-60,-80,-60,-40,-20,0,20,40,60,80);
anim_1_x=new Array(20,20,17,36,60,78,90,92,93,98,108,120,133,152,181);
anim_1_y=new Array(-20,-20,-33,-38,-38,-27,-2,25,51,84,113,141,162,212,253);
anim_2_x=new Array(20,20,2,3,4,5,6,7,8,9,10,12,13,15,18);
anim_2_y=new Array(-20,-20,-33,-38,-38,-27,-2,25,51,84,113,141,162,212,253);
anim_3_x=new Array(-20,-20,-2,-1,7,10,18,35,60,102,94,94,93,97,108,111,117,127);
anim_3_y=new Array(-20,-25,-64,-89,-104,-150,-173,-197,-213,-199,-151,-101,-66,-17,27,87,140,189);
anim_4_x=new Array(-20,-20,-10,-39,-30,-69,-64,-138,-154,-200,-181,-209,-191,-207,-203,-213,-202,-221,-211);
anim_4_y=new Array(-20,-20,-28,-51,-79,-100,-135,-154,-193,-183,-149,-134,-89,-60,8,51,107,157,201);
anim_5_x=new Array(-20,-29,-51,-72,-105,-133,-164,-189,-209,-229,-247,-270,-279,-282,-283,-283,-285,-286,-288);
anim_5_y=new Array(-20,-55,-86,-116,-154,-183,-205,-217,-217,-198,-169,-120,-44,-8,40,87,144,190,248);
anim_6_x=new Array(-20,-20,-7,14,44,79,143,186,217,226,234,244,250,259,265,274);
anim_6_y=new Array(-20,-21,-72,-113,-139,-166,-188,-181,-126,-68,-3,54,134,187,215,257);
anim_7_x=new Array(20,20,-3,-9,-13,-27,-33,-44,-54,-66,-77,-95,-107,-136,-150,-160,-164,-168,-171,-172,-172,-176,-175);
anim_7_y=new Array(-20,-26,-43,-63,-89,-116,-145,-169,-201,-222,-240,-253,-254,-245,-220,-195,-160,-124,-81,-53,-26,19,68);
anim_8_x=new Array(-20,20,-35,39,0,45,-1,24,-15,14,-20,35,-18,38,-11,16,49,64,81,93,100,103,109);
anim_8_y=new Array(-20,-20,-32,-42,-62,-76,-89,-107,-132,-147,-173,-180,-192,-209,-236,-193,-119,-73,-24,51,95,130,188);
anim_9_x=new Array(-20,-51,-89,-110,-165,-191,-228,-240,-259,-271,-277,-281,-287);
anim_9_y=new Array(-20,-20,-35,-37,-34,-16,10,47,105,150,189,227,273);
// End --
/script
!--第二步:把body改为--
body bgcolor="#fef4d9" OnLoad="initMouseEvents()"
!--第三步:在body区域中加入如下代码--
div id="sparks"
div id="sDiv0" style="position:absolute; visibility: hidden;"font face="arial black" color="red"a/font/div
div id="sDiv1" style="position:absolute; visibility: hidden;"font face="arial black" color="yellow"b/font/div
div id="sDiv2" style="position:absolute; visibility: hidden;"font face="arial black" color="blue"c/font/div
div id="sDiv3" style="position:absolute; visibility: hidden;"font face="arial black" color="red"d/font/div
div id="sDiv4" style="position:absolute; visibility: hidden;"font face="arial black" color="orange"e/font/div
div id="sDiv5" style="position:absolute; visibility: hidden;"font face="arial black" color="white"f/font/div
div id="sDiv6" style="position:absolute; visibility: hidden;"font face="arial black" color="green"g/font/div
div id="sDiv7" style="position:absolute; visibility: hidden;"font face="arial black" color="skyblue"h/font/div
div id="sDiv8" style="position:absolute; visibility: hidden;"font face="arial black" color="yellow"i/font/div
div id="sDiv9" style="position:absolute; visibility: hidden;"font face="arial black" color="white"j/font/div
/div
2
代码如下:
embed style="left: 50px; width: 850px; position: absolute; top: 100px; height: 500px" align=right src=http://bbs.flasher123.com/uploadfile/2004-9/200492417253374840.swf width=200 height=500 type=application/octet-stream ;; quality="high" wmode="transparent"/embed embed style="left: 50px; width: 850px; position: absolute; top: 600px; height: 600px" align=right src=http://bbs.flasher123.com/uploadfile/2004-9/200492417253374840.swf width=700 height=600 type=application/octet-stream wmode="transparent" quality="high" ;;/embed embed style="left: 50px; width: 850px; position: absolute; top: 1100px; height: 500px" align=right src=http://bbs.flasher123.com/uploadfile/2004-9/200492417253374840.swf width=500 height=500 type=application/octet-stream ;; quality="high" wmode="transparent"/embed embed style="left: 50px; width: 850px; position: absolute; top: 1600px; height: 600px" align=right src=http://bbs.flasher123.com/uploadfile/2004-9/200492417253374840.swf width=500 height=600 type=application/octet-stream wmode="transparent" quality="high" ;;/embed embed style="left: 50px; width: 850px; position: absolute; top: 2100px; height: 500px" align=right src=http://bbs.flasher123.com/uploadfile/2004-9/200492417253374840.swf width=500 height=500 type=application/octet-stream ;; quality="high" wmode="transparent"/embed embed style="left: 50px; width: 850px; position: absolute; top: 2600px; height: 500px" align=right src=http://bbs.flasher123.com/uploadfile/2004-9/200492417253374840.swf width=500 height=500 type=application/octet-stream ;; quality="high" wmode="transparent"/embed embed style="left: 50px; width: 850px; position: absolute; top: 3100px; height: 500px" align=right src=http://bbs.flasher123.com/uploadfile/2004-9/200492417253374840.swf width=500 height=500 type=application/octet-stream ;; quality="high" wmode="transparent"/embed
表白烟花代码
天天敲代码的朋友,有没有想过代码也可以变得很酷炫又浪漫?今天就教大家用Python模拟出绽放的烟花,工作之余也可以随时让程序为自己放一场烟花秀。
python炫酷烟花表白源代码
这个有趣的小项目并不复杂,只需一点可视化技巧,100余行Python代码和程序库Tkinter,最后我们就能达到下面这个效果:
学完本教程后,你也能做出这样的烟花秀。
整体概念梳理
我们的整个理念比较简单。
我们这里通过让画面上一个粒子分裂为X数量的粒子来模拟爆炸效果。粒子会发生"膨胀”,意思是它们会以恒速移动且相互之间的角度相等。这样就能让我们以一个向外膨胀的圆圈形式模拟出烟花绽放的画面。经过一定时间后,粒子会进入"自由落体”阶段,也就是由于重力因素它们开始坠落到地面,仿若绽放后熄灭的烟花。
关于VC或者MFC编程环境下,烟花绽放程序的C代码
可惜一开始没能画成圆,所以整个过程都是菱形的变换,希望大家多多指教,能够想办法把初始状态就围成一个圆.
#include "stdlib.h"
#include"graphics.h"
main()
{int gd=DETECT,gr,a[8],b[8],x,y,i,j,c;
initgraph(gd,gr,"");
randomize();
for(;!kbhit();)
{x=rand()%500+100; /*随机中心坐标*/
y=rand()%300+100;
a[0]=x; /*各点坐标的计算,我的烟花图形没能是圆的*/
b[0]=y-10;
a[1]=a[0]+5;
a[2]=a[1]+5;
a[3]=a[1];
a[4]=a[0];
a[5]=a[0]-5;
a[6]=a[5]-5;
a[7]=a[6]+5;
for(j=1;j5;j++)
b[j]=b[j-1]+5;
for(j=5;j8;j++)
b[j]=b[j-1]-5;
for(j=0;j6;j++) /*烟花的大小设定*/
{
for(i=0;i8;i++)
{
c=rand()%13+1; /*各点的颜色随机*/
setcolor(c);
circle(a[i],b[i],1);
}
delay(5000);
cleardevice();
b[0]-=10; /*各点的坐标变换*/
a[1]+=5;
b[1]-=5;
a[2]+=10;
a[3]+=5;
b[3]+=5;
b[4]+=10;
a[5]-=5;
b[5]+=5;
a[6]-=10;
a[7]-=5;
b[7]-=5;
}
}
getch();
closegraph();
}
百度上java烟花代码改成按类编写,改变其烟花消失方式,实现鼠标一点实现多个烟花绽放
喔哇,
都是啥子年代了,
还食古不化,
在触摸屏幕用手指划动而产生燃放烟花的虚拟图像效果,
早就被时代彻底底抛弃了!!
现在都是在空中一划,根据手势,根据手势的空间运动,
立即就是实际来真格的,
真实、震撼、空间大爆炸、场面骇人、惊天动地。
无接触,
摒弃虚拟的虚假玩意儿。
你吹一口气,
燃放装置就喷出一股火焰。
机械加工能力和基础强劲的,
产生1米边长见方立体焰火造型,
与产生100米见方焰火造型的设备是通用的。
你与情侣自拍“刷脸”就立即产生肖像燃放造型,
其详细的工程技术细节,
早就有中英文对照的文本,
照着去做就可以了,
无需操作机床加工的人员,
去“进一步研究思考”、去开展“创造性的工作”。
flash烟花代码是什么?
var FireTimer:Timer=new Timer(1000);
FireTimer.addEventListener(TimerEvent.TIMER,addFire);
FireTimer.start();
var tempRo:Number;
function addFire(e:TimerEvent):void
{
var X:Number=Math.random()*550;
var Y:Number=Math.random()*400;
var color:uint=0xffffff* Math.random();
trace(color.toString());
for(var i:int=0;i100;i++)
{
var mc :MovieClip=new MovieClip();//定义一个影片剪辑
mc.graphics.beginFill(color);//影片剪辑的颜色
mc.graphics.drawCircle(0,0,4+3* Math.random());//绘制随机大小的圆
mc.graphics.endFill();
addChild(mc);
mc.x=X;
mc.y=Y;
mc.scaleX=mc.scaleY=0.4+Math.random()*0.6;
tempRo=Math.random()*360/180;
mc.spdX=Math.random()*10*Math.sin(tempRo)*Math.pow(-1,Math.floor(Math.random()*100)%2);
mc.spdY=Math.random()*10*Math.cos(tempRo)*Math.pow(-1,Math.floor(Math.random()*100)%2);
mc.addEventListener(Event.ENTER_FRAME,FireMove);
}
}
function FireMove(e:Event):void
{
var obj:Object=e.target;
obj.x+=obj.spdX;
obj.y+=obj.spdY;
obj.alpha-=0.05;
if(obj.alpha=0)
{
obj.removeEventListener(Event.ENTER_FRAME,FireMove);
}
}
新建一个AS3文档,把这些代码放到第一帧,CTRL+ENTER,OK了,烟花就出现了!这是我自己写的,你可以看一下。效果有的,只是不怎么好看。
c语言放烟花代码
# define PI 3.14
#includegraphics.h
#includestdio.h
#includestdlib.h
#includebios.h
#includemath.h
#includetime.h
#includealloc.h
#includeconio.h
#includedos.h
#includestring.h
void star(int x,int y);
void drawstar();
void Putstar(void);
void starflower();
int main()
{
int gdriver=DETECT;
int gmode=0;
initgraph(gdriver,gmode,"c:\\tc20\\bgi");
drawstar();
starflower();
getch();
closegraph();
return 0;
}
void star(int x,int y)
{
int i,a;
int n=5;
int x1[5],y1[5],x2[5],y2[5];
setcolor(YELLOW);
for(i=0;i5;i++)
{
x1[i]=x+n*cos(i*72*PI/180);
y1[i]=y+n*sin(i*72*PI/180);
x2[i]=x+n/2*cos(i*72*PI/180+PI/5);
y2[i]=y+n/2*sin(i*72*PI/180+PI/5);
}
for(i=0;i5;i++)
{
a=i+1;
if(a4) a=0;
line(x1[i],y1[i],x2[i],y2[i]);
line(x2[i],y2[i],x1[a],y1[a]);
}
}
void Putstar(void)
{
int seed=1858;
int i,dotx,doty,h,w,color,maxcolor;
w=getmaxx();
h=getmaxy();
srand(seed);
for(i=0;i100;++i)
{dotx=i+random(w-1);
doty=1+random(h-1);
color=random(h-1);
setcolor(color);
putpixel(dotx,doty,color);
circle(dotx+1,doty+1,1);
}
srand(seed);
}
void drawstar()
{
int a[]={70,280,230,440,140,110,180,90,500,360};
int b[]={50,27,88,99,100,37,67,98,60,78},i;
setfillstyle(1,14);
for(i=0;i10;i++)
{
star(a[i],b[i]);
floodfill(a[i],b[i],YELLOW);
}
Putstar();
}
void starflower()
{
int i=0,j,n=60,n1=2;
int x=200,y=200,size=100;
int cover=0;
int delay1=20;
int wid,hei;
int px,py;
int color=9;
while(!kbhit())
{
if(isize)
{
for(j=0;jn;j++)
{
px=x+i*cos(j*360/n*PI/180);
py=y+i*sin(j*360/n*PI/180);
putpixel(px,py,rand()%16);
putpixel(px-1,py,color);
putpixel(px,py+1,color);
putpixel(px+1,py-1,YELLOW);
putpixel(px,py-1,YELLOW);
putpixel(px+1,py,RED);
putpixel(px+1,py+1,RED);
}
}
if(isizecoversize)
{
setcolor(BLACK);
circle(x,y,cover++);
delay1=20;
}
if(cover==size)
{
i=0;
x=50+rand()%550;
y=rand()%400;
cover=0;
color=rand()%16;
size=50+rand()%250;
delay1=40;
clearviewport();
drawstar();
}
i+=n1;
delay(delay1);
}
}
在编写那个烟花的程序(java),以下是对烟花进行绘制的代码,我是新手看不懂,请帮忙解释下呢··
就是找了三个随机数, r,g,b作为颜色的初始色彩,在三个数字上偏移, 得到相近的颜色.. 并画出来..