給小時鐘打光

2021-08-30 16:17:23 字數 3506 閱讀 3960

在昨天的基礎上,加入了燈光和旋轉,當打入燈光後,時鐘立刻就有了立體感,並且按0可以切換燈光的關閉和開啟,左右鍵可以讓時鐘進行旋轉。明天加上探照燈的功能。

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.linq;

using system.text;

using system.windows.forms;

using tao.opengl;

using tao.freeglut;

namespace homework3

private void setvolume()

private void myinit()

;float light0_ambient = new float[4] ;

float light0_diffuse = new float[4] ;

float light0_specular = new float[4] ;

gl.gllightmodelfv(gl.gl_light_model_ambient, global_ambient);

gl.gllightfv(gl.gl_front_and_back, gl.gl_ambient, light0_ambient);

gl.gllightfv(gl.gl_front_and_back, gl.gl_diffuse, light0_diffuse);

gl.gllightfv(gl.gl_front_and_back, gl.gl_specular, light0_specular);

gl.glcolormaterial(gl.gl_front_and_back, gl.gl_ambient_and_diffuse);

gl.glenable(gl.gl_color_material);

gl.glenable(gl.gl_lighting);

gl.glenable(gl.gl_light0);

gl.glenable(gl.gl_depth_test);

status = 0;

}private void ******openglcontrol1_load(object sender, eventargs e)

private void ******openglcontrol1_paint(object sender, painteventargs e)

;float material_diffuse = new float[4] ;

float material_specular = new float[4] ;

gl.glmaterialfv(gl.gl_front_and_back, gl.gl_ambient, material_ambient);

gl.glmaterialfv(gl.gl_front_and_back, gl.gl_diffuse, material_diffuse);

gl.glmaterialfv(gl.gl_front_and_back, gl.gl_specular, material_specular);

gl.glmaterialf(gl.gl_front_and_back, gl.gl_shininess, 35.0f);

gl.glrotated(rot, 0.0, 1.0, 0.0);

gl.glcolor3ub(0, 255, 0);

glut.glutsolidtorus(0.15, 1.5, 40, 40);

gl.glpushmatrix();

gl.glcolor3ub(255, 255, 0);

gl.glscaled(1.0, 1.0, 0.1);

glut.glutsolidsphere(1.35, 40, 40);

gl.glpopmatrix();

gl.glpopattrib();

gl.gltranslated(0.0, 0.0, 0.15);

if (rot < 90 && rot > -90)

;float light_direction = new float[3] ;

gl.glenable(gl.gl_color_material);

gl.gllightfv(gl.gl_light1, gl.gl_position, light_position);

gl.gllightfv(gl.gl_light1, gl.gl_spot_direction, light_direction);

gl.gl_spot_cutoff, (float)(math.atan(2.0) * 180.0 / math.pi));

gl.glpushmatrix();

gl.glcolor3ub(255, 255, 255);

gl.gltranslated(-1.45 * math.sin(60 * math.pi / 180.0), -1.45 * math.cos(60 * math.pi / 180.0), 0.1);

gl.gldisable(gl.gl_lighting);

glut.glutsolidsphere(0.15, 20, 20);

gl.glenable(gl.gl_lighting);

gl.glpopmatrix();

gl.gldisable(gl.gl_color_material);

}gl.glpopattrib();}}

private void timer1_tick(object sender, eventargs e)

this.******openglcontrol1.refresh();

}private void ******openglcontrol1_keydown(object sender, keyeventargs e)

else

break;

case keys.left:

if (rot >= 270 )

rot = -90;

rot += 5;

break;

case keys.right:

if (rot <= -270)

rot = 90;

rot -= 5;

break;

case keys .d1:

if (light1_status == 1)

else

break;

case keys.d2:

break;

case keys.d3:

break;

case keys.d4:

break;

}this.******openglcontrol1.refresh();}}

}

呵呵,洗個澡,然後複習組合數學,下個禮拜又要進行第二次組合數學的期中考試,還有se的階段性考試,哎,又要累了。。。

html css js的小時鐘

在body中用svg格式實現時鐘的繪製,在script標籤中定義更新事件的方法,並通過setinternal函式實現重複繪製。通過將時間的變化轉換為在鐘面上的旋轉角度,把相應的svg元素進行旋轉,實現時分秒中的轉動。沒有將css樣式渲染寫在單獨的檔案中,而是定義在head標籤部分,style裡定義的...