ただのメモ

他の人に見せても良い方のメモ

鬼滅の刃の市松模様

import numpy as np
import matplotlib.pyplot as plt
import math
import random
random.seed(314)

"""
$-1 parameter input$
"""
N=121
cn=11

"""
$1 making polygon$
"""
x=np.array([-0.5,0.5,0.5,-0.5])
y=np.array([0,0,1,1])

xl=list()
yl=list()
for i in range(N):
  xl.append(x+1*(i%cn))
  yl.append(y-1*int(i/cn))

"""
$2 defining color of polygon$
"""
def col(x):
    if x % 2 == 0:
        return "green"
    elif x % 2 == 1:
        return "black"

"""
$3 making figure$
"""
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_aspect('equal')

for i in range(N):
    poly = plt.fill(xl[i],yl[i],fc=col(i))

plt.show()