和柄(竹)

def setup():
    size(300, 300) #画面サイズ
    
def draw():
    background(222, 241, 173)
    strokeWeight(0)
    fill(108, 191, 119)
    drawTake2(150, 300, 50, 140)
    drawTake2(150, 155, 50, 140)

def drawTake(posX, posY, w, h):
    beginShape()
    x1 = posX - w / 2
    y1 = posY
    x2 = posX - w / 4
    y2 = posY - h / 3
    x3 = posX - w / 4 
    y3 = posY - h / 3 * 2
    x4 = posX - w / 2
    y4 = posY - h
    vertex(x1, y1) #左下
    bezierVertex( x2, y2, x3, y3, x4, y4) #左側面から左上
    x1 = posX + w / 2
    y1 = posY - h
    x2 = posX + w / 4 
    y2 = posY - h / 3 * 2
    x3 = posX + w / 4
    y3 = posY - h / 3
    x4 = posX + w / 2
    y4 = posY
    vertex(x1, y1) #右上
    bezierVertex( x2, y2, x3, y3, x4, y4) #右側面から右下
    endShape()
    
def drawTake2(posX, posY, w, h):
    yureW = w / 10
    yureH = h / 3
    beginShape()
    x1, y1 = posX - w / 2, posY
    x2, y2 = posX - w / 4, posY - h / 3
    x3, y3 = posX - w / 4, posY - h / 3 * 2 
    x4, y4 = posX - w / 2, posY - h
    x2, y2 = yuragi(x2, y2, yureW, yureH)
    x3, y3 = yuragi(x3, y3, yureW, yureH)
    vertex(x1, y1) #左下
    bezierVertex( x2, y2, x3, y3, x4, y4) #左側面から左上
    x1, y1 = posX + w / 2, posY - h
    x2, y2 = posX + w / 4, posY - h / 3 * 2 
    x3, y3 = posX + w / 4, posY - h / 3
    x4, y4 = posX + w / 2, posY
    x2, y2 = yuragi(x2, y2, yureW, yureH)
    x3, y3 = yuragi(x3, y3, yureW, yureH)
    vertex(x1, y1) #右上
    bezierVertex( x2, y2, x3, y3, x4, y4) #右側面から右下
    endShape()
    
def yuragi(x, y, yureW, yureH):
    x = x + random(-yureW, yureW)
    y = y + random(-yureH, yureH)
    return x, y

コメントする