# Untitled

unknown
python
a year ago
1.9 kB
2
Indexable
Never
```print("\033c")
import numpy as np
import matplotlib.pyplot as plt

# The user informs the coordinates of the two points for the line.
y1 = 100;x1 = 100
y2 = 200;x2 = 200
y3 = 300;x3 = 300
y4 = 400;x4 = 400

#The user decides the point diameter
pd = 20
#Calculate the half diameter
hd = int(pd/2)

#The user decides the line width
lw = 10

#Calculate the half line width
hw = int(lw/2)

#Setting the size of the canvas
row = int(500)
col = int(500)
print('col, row =', col, ',', row)

#Preparing the black canvas
Gambar = np.zeros(shape=(row, col, 3), dtype=np.uint8)
Gambar[:, :, :] = 255 # Mengubah layar menjadi putih

# Looping membuat Titik berbentuk Kotak
# for i in range(y1-hd, y1+hd+1): #start : 95, stop: 106
#     for j in range(x1-hd, x1+hd+1): #start : 95, stop: 106
#         Gambar[i, j, 0] = 255
#
# for i in range(y2-hd, y2+hd+1): #start : 95, stop: 106
#     for j in range(x2-hd, x2+hd+1): #start : 95, stop: 106
#         Gambar[i, j, 0] = 255

#Coloring the two points red(loop, condition, comparation)
for i in range(x1-hd, x1+hd+1):
for j in range(y1-hd, y1+hd+1):
if( (i-x1)**2 + (j-y1)**2) < hd ** 2:
Gambar[j, i, :] = 0
Gambar[j, i, 0] = 255

for i in range(x2-hd, x2+hd+1):
for j in range(y2-hd, y2+hd+1):
if( (i-x2)**2 + (j-y2)**2) < hd ** 2:
Gambar[j, i, :] = 0
Gambar[j, i, 0] = 255

for i in range(x3-hd, x3+hd+1):
for j in range(y3-hd, y3+hd+1):
if( (i-x3)**2 + (j-y3)**2) < hd ** 2:
Gambar[j, i, :] = 0
Gambar[j, i, 0] = 255

for i in range(x4-hd, x4+hd+1):
for j in range(y4-hd, y4+hd+1):
if( (i-x4)**2 + (j-y4)**2) < hd ** 2:
Gambar[j, i, :] = 0
Gambar[j, i, 0] = 255

plt.figure()
plt.imshow(Gambar)
plt.show()```