2011-12-01から1ヶ月間の記事一覧

イベントハンドラ

clicke meをクリックしたらイベントが実行される。 <html> <head> <title>テスト</title> </head> <body> <div onClick="alert('clicked')"> clicke me </div> </script> </body> </html>

乱数(javascript)

1から10までの乱数を7個生成する。 <html> <head> <title>テスト</title> </head> <body> <script type="text/javascript"> <!-- for(i = 0; i < 7; i++) { document.write(Math.floor(Math.random()*10+1) + "<br>"); } // --> </script> </body> </html>

ウィンドウ生成(javascript)

javascriptでウィンドウ生成する。 <html> <head> <title>テスト</title> </head> <body> <script type="text/javascript"> <!-- document.write("どうしようか?"); // --> </script> </body> </html>

アニメーション(opengl)

赤い球を中心に緑、青、紫の球が回転する。 #include<stdlib.h> #include<GL/glut.h> int angle1 = 0, angle2 = 0, angle3 = 0; void init(char *name) { int width = 300, height = 300; glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(width, height); glutC</gl/glut.h></stdlib.h>…

照明

平行光源の拡散光をz軸方向からティーポットに当てる。 #include<GL/glut.h> int angle = 0; void init(char *name) { int width = 200, height = 200; GLfloat light_position[] = {0.0, 0.0, 1.0, 0.0}; GLfloat light_color[] = {0.4, 1.0, 0.0, 0.0}; glutInitDisp</gl/glut.h>…

回転するティーポット

「r」と「l」でティーポットが回転する。 #include<GL/glut.h> int angle = 0; void init(char *name) { int width = 200, height = 200; glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow(name); glClearColor(0.0, 0.0, 0.0, 1.</gl/glut.h>…

基本の2D

#include<GL/glut.h> void init(char *name) { glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(200, 200); glutCreateWindow(name); glClearColor(1.0, .0, 0.0, 1.0); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3d(1.0, 1.0, 0.0); glBegin(</gl/glut.h>…

マウス操作(クリック)

右クリックでティーポットを小さく、左クリックでティーポットを大きくする。 #include<stdio.h> #include<GL/glut.h> double size = 1.0; void init(char *name) { int width = 300, height = 300; glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(width, height); glutCre</gl/glut.h></stdio.h>…

sqlite3によるSQL入門

平均点が80点以上 d:\sql>sqlite3 test.db SQLite version 3.7.9 2011-11-01 00:52:41 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table person(name text, score integer); sqlite> insert into person …

sqlite3によるSQL入門

group byでname毎のscoreの集計を行う。 d:\sql>sqlite3 test.db SQLite version 3.7.9 2011-11-01 00:52:41 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table person(name text, score integer); sqlite> …