Presentation is loading. Please wait.

Presentation is loading. Please wait.

多 媒 體 安 全多 媒 體 安 全 指導教授 : 黃文楨 班級 : 企電所 1A 學號 : 9722811 姓名 : 王嘉苑 ImageJ BouncingBar.

Similar presentations


Presentation on theme: "多 媒 體 安 全多 媒 體 安 全 指導教授 : 黃文楨 班級 : 企電所 1A 學號 : 9722811 姓名 : 王嘉苑 ImageJ BouncingBar."— Presentation transcript:

1 多 媒 體 安 全多 媒 體 安 全 指導教授 : 黃文楨 班級 : 企電所 1A 學號 : 9722811 姓名 : 王嘉苑 ImageJ BouncingBar

2 BouncingBar 主要功能 : 產生一張有框的圖片,這個圖片內會產 生顏色漸層出現的 bar ,然後將這個 bar 設定只會出現在框內。

3 程式解釋 width = 600; 設定 image 的寬 height = 200; 設定 image 的長 newImage(“Untitled”, “RGB”, width, height, 1); 產生一張新的圖片,如果沒有設定 “RGB” 就會 顯示 “8-bit” 灰階的圖片 lw = width/15; 設定 bar 的寬度 lw2 = lw/2; 設定框與圖的間距

4 snapshot(); create a backup image that can be restored later. autoUpdate(false); disable automatic display updates. x1=0.2*width; y1=0.5*height; x2=0.8*width; y2=y1; 設定 x1,y1,x2,y2 的初始值, 為 bar 的座標 inc=2; x1inc=0.5*inc; y1inc=-inc; x2inc=-inc; y2inc=0.5*inc; x1inc,y1inc,x2inc,y2inx 這邊變數將會跟 x1,y1,x2,y2 想加減來改變 bar 出現的位置 rinc=1; binc=1; ginc=0.5; 這些變數將會跟 r.g.b 相加減產生 不同的顏色 r=255; g=0; b=0; 設定 r.g.b 的初始值

5 while (true) { 開始無線迴圈 x1+=x1inc; x1=120,x1inc=1 Value=120,121,122,~579,578,577,~21,22~23~579 y1+=y1inc; y1=100,y1inc=-2 Value=100,98,96,~~22, 24,26,~~178,176,174~22 x2+=x2inc; x2=480,x2inc=-2 Value=480,478,476,~~22, 24,26,~~578,576,574~22 y2+=y2inc; y2=100,y2inc=1 Value=100,101,~~179,178,177,~ 21,22,23~179

6 設定 x1,y1,x2,y2 於 x=20~580,y=20~180 if (x1 =width-lw2) x1inc=-x1inc; 把 x1 介 於 x 座標 20~580 之間 if (y1 =height-lw2) y1inc=-y1inc; 把 y1 介 於 y 座標 20~180 之間 if (x2 =width-lw2) x2inc=-x2inc; 把 x2 介 於 x 座標 20~580 之間 if (y2 =height-lw2) y2inc=-y2inc; 把 y2 介 於 y 座標 20~180 之間

7 設定 r.g.b 的值 r-=rinc; g+=ginc; b+=binc; if (r =255) rinc=-rinc; 從 254 一直減到 0 在從 0 增加到 254 if (g =255) ginc=-ginc; 從 1 一直增加到 254 在 從 254 減少到 1 if (b =255) binc=-binc; 從 0.5 一直增加到 254 在從 254 減少到 0.5

8 reset(); restore the backup image setColor(r,g,b); bar's color setLineWidth(lw); bar's width drawLine(x1,y1,x2,y2); draw a bar updateDisplay(); update the image } 如果沒有設定 reset() 將產生 以上這張圖


Download ppt "多 媒 體 安 全多 媒 體 安 全 指導教授 : 黃文楨 班級 : 企電所 1A 學號 : 9722811 姓名 : 王嘉苑 ImageJ BouncingBar."

Similar presentations


Ads by Google