1 / 15

Project 4 The Dragon Curve

Project 4 The Dragon Curve. 組別:第七組 報告者:數學三 00131042 蘇育萱 數學三 00131052 方思婷. Project Description. 使用 PIL(Python Image Library) 描繪出二維空間的曲線。 輸入檔案 (dragon_1.txt, dragon_2.text, dragon_3.text) 讀取字串. 100 * 100. 方向. 起始點. pixel. Project Description. 每一次移動的長度皆 為 10 pixel

tocho
Télécharger la présentation

Project 4 The Dragon Curve

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project 4 The Dragon Curve 組別:第七組 報告者:數學三 00131042 蘇育萱 數學三 00131052 方思婷

  2. Project Description • 使用PIL(Python Image Library) 描繪出二維空間的曲線。 • 輸入檔案(dragon_1.txt, dragon_2.text, dragon_3.text)讀取字串 100*100 方向 起始點 pixel

  3. Project Description • 每一次移動的長度皆為 10 pixel • 起始位置必須在視窗的中間 • 這些字串所描繪出來的曲線為DragonCurve • 這份報告要使用 PIL ImageDraw, PIL Image, and random • 使用random library 產生一個隨機正整數N

  4. TODO1 • 寫出一個函數: colorPixel(position, color, myImage) • 寫出一個函數,設定它的位置與顏色。 將像素寫為新的影像檔(將位置與顏色寫入myImage當中)

  5. TODO2 • 寫出一個函數: flipAxis(position, bounds) • 利用此函數改變座標系,將原點(0,0)從左上角移至左下角

  6. TODO3 • 寫出一個函數: checkBounds(position, bounds) • 確認位置: (1)如果位置在圖像的變界外,就必須 重設位置至最靠近邊界的位置。 (2)如果位置在邊界的內部,就不需重 設位置,直接將現在的位置回傳至 函數checkBounds。

  7. TODO4 • 寫出一個函數: drawLine(position, direction, color, myImage) • 這個函數是要回傳每一次畫出一條10pixel⻑度線的末端點,⽅向是被輸入的參數(direction)值所指定。 • (direction is a singlecharacter(’N’,’E’,’S’,’W’)) Discard the top element on the stack.

  8. TODO5 • 寫出一個函數: main() • 這個函數必須遵守: • 1.詢問使用者輸⼊檔案的名字 • 2.詢問使用者顏色 • 3.轉換顏色字串變成 r,g,b(Ex:red→(255,0,0))

  9. 4.打開輸入的檔案,其內容包含方向及像數 • 5.讀取被輸入檔案的資料 remove leading and trailing whitespace

  10. 6.根據資料畫出dragon curve: 當你正在畫曲線時,並將每一次移動後的線段 的端點存成一個清單。 • 7.將圖⽚存檔: 圖片的名稱必須為dragon_image_#.jpeg • 8.save the movement list to a texe file將每一次移動後的現段點儲存成清單並且檔案名稱為dragon_moves_#.txt • #=1,2,3

  11. 執行程式應該看起來像下方所示 Please input file to open: Please input color (red, green, blue, orraom): Thank you come again

  12. TestCase1 • a. file : dragon_1.txt • b. color : orange • c. output : dragon_moves_1.txt

  13. TestCase2 • a. file : dragon_2.txt • b. color : red • c. output : dragon_moves_2.txt

  14. TestCase3 • a. file : dragon_3.txt • b. color : random • c. output : dragon_moves_3.txt ……

  15. THE END

More Related