Hello
I have always been fascinated with aliasing, and I am sitting with a project that implements aliasing as a deliberate aesthetical choice. I guess that it’s all about duplicating values, so I wrote this code that takes a list of values, and outputs a modified list with duplicates. This would have to be done for both x-axis and y-axis.
So for instance: A list like
[[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,15]]
when processed with a factor of 2 for both x-axis and y-axis, would produce
[[1, 1, 3, 3], [1, 1, 3, 3], [9, 9, 11, 11], [9, 9, 11, 11]]
I have come to the following solution:
l = [
[1,2,3,4],
[5,6,7,8],
[9,10,11,12],
[13,14,15,16]
]
valx,valy = 2,2 # repetition factors, can be set individually for each axis
halpx,halpy = 0,0 # helper variables for counting
out = [] # the final list
# duplicating the x-axis: repeat values for the x-axis (factor set by valx)
print("x-axis:")
for sublist in l:
for i in range(len(sublist)):
if halpx % valx != 0:
sublist[i] = sublist[i-1]
halpx += 1
print(l)
print("y-axis:")
# duplicating the y-axis: repeat values for the y-axis (factor set by valy)
for sublist in l:
if halpy % valy == 0:
for i in range(valy):
out.append(sublist)
halpy += 1
out = out[:len(l)]
print(out)
This works just fine. But I was wondering if there were better and faster ways of doing this. Thanks for taking a look!