MCPcopy Create free account
hub / github.com/ICE27182/Python-3D-renderer / add_line

Function add_line

pyrender.py:1167–1193  ·  view source on GitHub ↗
(M, N)

Source from the content-addressed store, hash-verified

1165
1166
1167 def add_line(M, N):
1168 if M[8] == N[8]:
1169 if 0 <= M[8] < cam.width:
1170 if M[9] > N[9]:
1171 M, N = N, M
1172 for y in range(max(0, M[9]), min(cam.height - 1, N[9])):
1173 frame[y][M[8]] = (127, 127, 127)
1174 elif abs(k:=(M[9] - N[9]) / (M[8] - N[8])) <= 1:
1175 b = M[9] - k * M[8]
1176 if M[8] > N[8]:
1177 M, N = N, M
1178 for x in range(max(0, M[8]), min(cam.width - 1, N[8])):
1179 # CodeUndone
1180 y = int(k * x + b)
1181 if 0 <= y < cam.height:
1182 frame[y][x] = (127, 127, 127)
1183 # frame[int(k * x + b)][x] = (127, 127, 127)
1184 else:
1185 t = 1 / k
1186 b = M[8] - t * M[9]
1187 if M[9] > N[9]:
1188 M, N = N, M
1189 for y in range(max(0, M[9]), min(cam.height - 1, N[9])):
1190 x = int(t * y + b)
1191 if 0 <= x < cam.width:
1192 frame[y][x] = (127, 127, 127)
1193 # frame[y][int(t * y + b)] = (127, 127, 127)
1194
1195
1196 def rasterize_solid(A, B, C, normal):

Callers 3

renderFunction · 0.85
add_lightsFunction · 0.85
add_obj_dirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected