原件存檔 Original files吳哲宇 Che-Yu Wu

高二上(2011 年 10 月)Grade 11, first term (October 2011)

Majer Comic:用 11 根滑桿調出一張臉Majer Comic: a face adjusted with eleven sliders

視窗裡是一張只有線條的臉,右邊有 11 根滑桿:臉中心的 X 和 Y、兩眼的間距、嘴的寬度、眼到鼻、鼻到嘴、嘴到下巴的距離、眼睛的寬和高、嘴的寬和高。臉的輪廓由一串控制點決定,每個控制點有兩個數字,離眼睛那一行多遠(d),和那裡的半臉寬(width)。程式先放 6 個點:眼、鼻、嘴、下巴、頭頂,再加一個額頭中間。兩側各用這串點畫一條 DrawCurve 曲線,一條取正的寬度,一條取負的,合起來就是左右對稱的臉。

左上角的清單列出每個控制點的 D 和 W,三顆按鈕叫 create、draw、clear。還可以自己在文字框輸入 d 和 width,加一個控制點,或勾選「show」,用滑鼠拖方塊直接改輪廓。專案裡沒有留下畫面的截圖,所以這一筆沒有圖。

The window shows a face of lines only, with 11 sliders on the right: the face centre's X and Y, the distance between the eyes, the width of the mouth, the distances from eyes to nose, nose to mouth and mouth to chin, the width and height of the eyes, and the width and height of the mouth. The outline comes from a list of control points, each with two numbers: how far it lies from the eye line (d) and the half-width of the face there (width). The program starts with 6 points, eye, nose, mouth, chin and top of the head, plus one in the middle of the forehead. Each side draws a DrawCurve through the list, one with the width taken as positive and one as negative, and together they make a left-right symmetrical face.

A list at the upper left shows each control point's D and W, and three buttons are called create, draw and clear. You can also type d and width into the text boxes to add a control point, or tick "show" and drag the boxes with the mouse to reshape the outline. The project left no screenshot, so this record has no picture.

    Public Function reset_facecontrol()
        faceWidthcol.Clear()
        For i As Integer = 0 To newfacecontrolnum - 1
            add_new_facecontrol(newfacecontrol(i).d, newfacecontrol(i).width)
        Next
        add_new_facecontrol(0, W_eye)
        add_new_facecontrol(D_eye_nose, W_eye - 5)
        add_new_facecontrol(D_eye_nose + D_nose_mouth, W_mouth)
        add_new_facecontrol(D_eye_nose + D_nose_mouth + D_mouth_chin, 0)
        add_new_facecontrol(0 - H_head, 0)
        add_new_facecontrol(0 - 0.5 * H_head, W_eye * 1.01)
        Return True
    End Function
    …
        Dim p(1) As PointF
        Dim c(2) As PointF
        Dim objFaceWidth As New clsFaceWidth
        Dim f1c(faceWidthcol.Count - 1) As PointF
        Dim temp As Integer = 0
        For Each objFaceWidth In faceWidthcol
            f1c(temp).X = objFaceWidth.width + middleX
            f1c(temp).Y = objFaceWidth.d + middleY
            temp += 1
        Next
        g.DrawCurve(Pens.Black, f1c)
        Dim f2c(faceWidthcol.Count - 1) As PointF
        temp = 0
        For Each objFaceWidth In faceWidthcol
            f2c(temp).X = -objFaceWidth.width + middleX
            f2c(temp).Y = objFaceWidth.d + middleY
            temp += 1
        Next
        g.DrawCurve(Pens.Black, f2c)
clsHead.vb:六個起始控制點,和左右兩條輪廓曲線。clsHead.vb: the six starting control points and the two outline curves.
    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll, TrackBar2.Scroll, TrackBar3.Scroll, TrackBar4.Scroll, TrackBar5.Scroll, TrackBar6.Scroll, TrackBar7.Scroll, TrackBar8.Scroll, TrackBar9.Scroll, TrackBar10.Scroll, TrackBar11.Scroll
        Dim objHead As clsHead = objects("head")
        With objHead
            .middleX = TrackBar1.Value
            .middleY = TrackBar2.Value
            .W_eye = TrackBar3.Value
            .W_mouth = TrackBar4.Value
            .D_eye_nose = TrackBar5.Value
            .D_nose_mouth = TrackBar6.Value
            .D_mouth_chin = TrackBar7.Value
            .EyeWidth = TrackBar8.Value
            .EyeHeight = TrackBar9.Value
            .MouthWidth = TrackBar10.Value
            .MouthHeight = TrackBar11.Value
        End With
Form1.vb:11 根滑桿的值寫進臉的各個參數(TrackBar1 到 TrackBar11)。Form1.vb: the values of the 11 sliders written into the face's parameters (TrackBar1 to TrackBar11).