代码拉取完成,页面将自动刷新
def change_frame(self,index,direct,O_o,size):
frame = copy.deepcopy(self.frame)
flag = 0
print(frame)
if direct == 1:#上
for i in range(len(frame)):#直接修改
if i != index:
if abs(frame[i][3] - frame[index][3] - frame[index][1]) < 0.01:# or abs(frame[i][0] + frame[i][2] - frame[index][0] - frame[index][2]) < 0.01:
#frame1上边为frame2下边
frame[i][3] += size * O_o
frame[i][3] = round(frame[i][3],2)
frame[i][1] -= size * O_o
frame[i][1] = round(frame[i][1],2)
elif abs(frame[i][1] + frame[i][3] - frame[index][1] - frame[index][3]) < 0.01:
#frame1上边为frame2上边
frame[i][1] += size * O_o
frame[i][1] = round(frame[i][1],2)
frame[index][1] += size * O_o
frame[index][1] = round(frame[index][1],2)
elif direct == 2:#右
# for i in range(len(frame)):#情况1:区块右边刚好为另一块的左边
# if abs(frame[i][2] - frame[index][2] - frame[index][0]) < 0.01 and abs(frame[i][1] - frame[index][1]) < 0.01:
# flag = 1
for i in range(len(frame)):#直接修改
if i != index:
if abs(frame[i][2] - frame[index][2] - frame[index][0]) < 0.01:# or abs(frame[i][0] + frame[i][2] - frame[index][0] - frame[index][2]) < 0.01:
#frame1右边为frame2左边
frame[i][2] += size * O_o
frame[i][2] = round(frame[i][2],2)
frame[i][0] -= size * O_o
frame[i][0] = round(frame[i][0],2)
elif abs(frame[i][0] + frame[i][2] - frame[index][0] - frame[index][2]) < 0.01:
#frame1右边为frame2右边
frame[i][0] += size * O_o
frame[i][0] = round(frame[i][0],2)
frame[index][0] += size * O_o
frame[index][0] = round(frame[index][0],2)
self.frame = list(frame)
print(self.frame)
# print(frame)
# print(self.frame)
def get_frame(self):
frame = []
pattern = r"\\new.*?\[statico.*?\]"
match = re.findall(pattern,self.file_data,re.S)
for match_str in match:
# index = int(re.search(r"(?<=statico)\d(?=\])",match_str).group())
params = re.findall(r"[0-9\.]+",match_str)
# print(list(map(float,params))[1:-1])
frame.append(list(map(float,params))[1:-1])
self.frame = frame
def change_tex_frame(self):
print(self.frame)
# new_frames = []
pattern = r"\\new.*?\[statico.*?\]"
match = re.findall(pattern,self.file_data,re.S)
count = len(match)
for i in range(count):
if i == 1:
insertion = r"\newflowframe[1]{%.2f\textwidth}{%.2f\textheight}{%.2f\textwidth}{%.2f\textheight}[statico%d]" % (self.frame[i][0],self.frame[i][1],self.frame[i][2],self.frame[i][3],i)
else:
insertion = r"\newstaticframe[1]{%.2f\textwidth}{%.2f\textheight}{%.2f\textwidth}{%.2f\textheight}[statico%d]" % (self.frame[i][0],self.frame[i][1],self.frame[i][2],self.frame[i][3],i)
# print(match[i])
# print(insertion)
self.file_data = self.file_data.replace(match[i],insertion)
#修改红框高度[colframe=red!75!white,colback=white,width=\textwidth,height=0.3\textheight,boxrule=2pt]
pattern = r"\[colframe=red.*?pt\]"
match = re.findall(pattern,self.file_data,re.S)
count = len(match)
for i in range(count):
if i == 0:
insertion = r"[colframe=red!75!white,colback=white,height=%.2f\textheight,boxrule=2pt]" % self.frame[1][1]
elif i == 1:
insertion = r"[colframe=red!75!white,colback=white,height=%.2f\textheight,boxrule=2pt]" % self.frame[0][1]
else:
insertion = r"[colframe=red!75!white,colback=white,height=%.2f\textheight,boxrule=2pt]" % self.frame[i][1]
print(match[i])
print(insertion)
self.file_data = self.file_data.replace(match[i],insertion)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。