您的位置:首页 > 新闻 > 资讯 > 【教学类-64-08】20240629彩棒鱼骨图(五)AAB排列 6.5*1CM 6选2根 30种

【教学类-64-08】20240629彩棒鱼骨图(五)AAB排列 6.5*1CM 6选2根 30种

2025/1/8 11:08:28 来源:https://blog.csdn.net/reasonsummer/article/details/140063198  浏览:    关键词:【教学类-64-08】20240629彩棒鱼骨图(五)AAB排列 6.5*1CM 6选2根 30种

  47cbbb7fb5e8468ca3bd7139e086c8c9.png

 

 

背景需求:

【教学类-64-04】20240619彩棒鱼骨图(一)6.5*1CM 6根棒子720种-CSDN博客文章浏览阅读897次,点赞23次,收藏13次。【教学类-64-04】20240619彩棒鱼骨图(一)6.5*1CM 6根棒子720种https://blog.csdn.net/reasonsummer/article/details/139813897?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22139813897%22%2C%22source%22%3A%22reasonsummer%22%7Dhttps://blog.csdn.net/reasonsummer/article/details/139813897?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22139813897%22%2C%22source%22%3A%22reasonsummer%22%7Dhttps://blog.csdn.net/reasonsummer/article/details/139813897?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22139813897%22%2C%22source%22%3A%22reasonsummer%22%7Dhttps://blog.csdn.net/reasonsummer/article/details/139813897?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22139813897%22%2C%22source%22%3A%22reasonsummer%22%7D

【教学类-64-05】20240625彩棒鱼骨图(二)AB排列 6.5*1CM 6选2根 30种-CSDN博客文章浏览阅读669次,点赞12次,收藏8次。【教学类-64-05】20240625彩棒鱼骨图(二)AB排列 6.5*1CM 6选2根 30种https://blog.csdn.net/reasonsummer/article/details/139998667?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22139998667%22%2C%22source%22%3A%22reasonsummer%22%7Dhttps://blog.csdn.net/reasonsummer/article/details/139998667?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22139998667%22%2C%22source%22%3A%22reasonsummer%22%7Dhttps://blog.csdn.net/reasonsummer/article/details/139998667?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22139998667%22%2C%22source%22%3A%22reasonsummer%22%7D

 

【教学类-64-06】20240625彩棒鱼骨图(三)ABC排列 6.5*1CM 6选2根 120种-CSDN博客文章浏览阅读454次,点赞13次,收藏6次。【教学类-64-06】20240625彩棒鱼骨图(三)ABC排列 6.5*1CM 6选2根 120种https://blog.csdn.net/reasonsummer/article/details/140021632?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22140021632%22%2C%22source%22%3A%22reasonsummer%22%7Dhttps://blog.csdn.net/reasonsummer/article/details/140021632?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22140021632%22%2C%22source%22%3A%22reasonsummer%22%7D【教学类-64-07】20240625彩棒鱼骨图(四)ABB排列 6.5*1CM 6选2根 30种-CSDN博客文章浏览阅读732次,点赞29次,收藏11次。【教学类-64-07】20240625彩棒鱼骨图(四)ABB排列 6.5*1CM 6选2根 30种https://blog.csdn.net/reasonsummer/article/details/140022754?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22140022754%22%2C%22source%22%3A%22reasonsummer%22%7D

前期制作了6根彩色冰棍棒的不重复排列720种。

ABAB的排序方式30种

ABCABC排序方式120种。

ABBABB排序30种

再做AABAAB

也就是从6种颜色中任意选择2个颜色,第1个颜色*2,将AAB样式*2,测算发现6选2一共有30种不重复的排列。

 

与AB相同,但是B需要多一个,所以就AB*2,删除第3个数字,然后将ABB*2,一共只有6个鱼骨位置,就(AA+B)*2次

 

7191e79e39ab4000a76a4e0bb9c35e82.png

代码展示

'''
冰棍棒六色720种 鱼骨图 红橙黄绿蓝紫 AAB排序系列6抽3不重复30种 短款)6.5*1(长款) 11.5*1 大号(15*1.8) -乱序
时间:2024年6月26日
作者:星火讯飞 阿夏'''
from PIL import Image, ImageDraw
import os,random
from PIL import ImageFontpath=r'C:\Users\jg2yXRZ\OneDrive\桌面\鱼骨图'
new_path=path+r'\01jpg(6.5乘1)'
os.makedirs(new_path,exist_ok=True)# nnn=int(input('1.固定、2、随机'))name='6.5乘1'print('-----1、制作图卡--------')
# 六色所有排序方式 720种
import itertools
colors = ['01red', '02orange', '03yellow', '04green', '05blue', '06purple']
# 使用itertools.permutations生成所有不重复排序方式
combinations = list(itertools.permutations(colors,2))
result = sorted(combinations)print(result)
print(len(result))# 30种
# '01red', '02orange',# ()元祖里的内容乘以3
new_perms = [t * 2 for t in result]
print(new_perms)
print(len(new_perms))
# ('01red', '02orange','01red', '02orange',)news_perms = [(t[0], t[2],t[3]) for t in new_perms]
print(news_perms)
print(len(news_perms))
# ('01red', '02orange','02orange',)perms = [t * 2 for t in news_perms]
print(perms)
print(len(perms))
# [('01red', '02orange', '02orange', '01red', '02orange', '02orange'),# 打乱
random.shuffle(perms)
print(perms)
print(len(perms))
# 720个不重复的方法
# 720有几位数(个数)num_digits = len(str(len(perms)))
# 120
print(num_digits)
# 720就是3位数for a in range(len(perms)):# 打开图片image = Image.open(path+r'\鱼骨图.jpg')# 创建一个800*600的画布long=844wide=378s=6# 6根棒子canvas = Image.new('RGB', (long, wide), 'white')draw = ImageDraw.Draw(canvas)# 定义圆角矩形的参数# 棒子的圆心radius = 20# 左侧间距left = 220#  右侧间距right = 180# 棒子的间距padding = 30# 棒子的宽rect_width = float((long-left-right-padding*7)/6)print(rect_width)# 40# 棒子的高rect_height = float(rect_width*6.5)# 棒子的高度坐标padding2=float((wide- rect_height-20))# wide-padding*2# 计算每个圆角矩形的位置rect_positions = [(padding+left, padding2),(rect_width + padding * 2+left, padding2),(rect_width * 2 + padding * 3+left, padding2),(rect_width * 3 + padding * 4+left, padding2),(rect_width * 4 + padding * 5+left, padding2),(rect_width * 5 + padding * 6+left, padding2)]colors = perms[a]  #  绘制圆角矩形draw = ImageDraw.Draw(image)# 绘制圆角矩形for i, position in enumerate(rect_positions):x, y = positiondraw.rounded_rectangle([x, y, x + rect_width, y + rect_height], radius, fill=colors[i][2:], outline='black', width=1)# 设置字体路径和大小font_path = r'C:\Windows\Fonts\AdobeHeitiStd-Regular.otf'font_size = 40# 加载字体font = ImageFont.truetype(font_path, font_size)# 在指定位置绘制文字draw.text((200, 30), f'彩色鱼骨图AAB({name}CM)-{a+1:03d}', font=font, fill='black')# 保存图片image.save(new_path + fr'\{a+1:0{num_digits}d}.png')print('-----2、制作大图--------')
# 六色所有排序方式 720种# 使用itertools.permutations生成所有不重复排序方式from PIL import Image, ImageDraw
import itertoolspath = r'C:\Users\jg2yXRZ\OneDrive\桌面\鱼骨图'
new_path_jpg = path + r'\02jpg(6.5乘1)'
os.makedirs(new_path_jpg, exist_ok=True)name = '6.5乘1'for b in range(2):image = Image.open(path + r'\鱼骨图.jpg')long = 844wide = 378s = 6canvas = Image.new('RGB', (long, wide), 'white')draw = ImageDraw.Draw(canvas)radius = 20left = 220right = 180padding = 30rect_width = float((long - left - right - padding * 7) / 6)print(rect_width)rect_height = float(rect_width * 6.5)padding2 = float((wide - rect_height - 20))rect_positions = [(padding + left, padding2),(rect_width + padding * 2 + left, padding2),(rect_width * 2 + padding * 3 + left, padding2),(rect_width * 3 + padding * 4 + left, padding2),(rect_width * 4 + padding * 5 + left, padding2),(rect_width * 5 + padding * 6 + left, padding2)]colors = perms[a]draw = ImageDraw.Draw(image)# 绘制圆角矩形for i, position in enumerate(rect_positions):x, y = positiondraw.rounded_rectangle([x, y, x + rect_width, y + rect_height], radius, fill='white', outline='black', width=1)# 设置字体路径和大小font_path = r'C:\Windows\Fonts\AdobeHeitiStd-Regular.otf'font_size = 40# 加载字体font = ImageFont.truetype(font_path, font_size)# 在指定位置绘制文字draw.text((150, 30), f'彩色鱼骨图AAB({name}CM)-操作图{b+1}', font=font, fill='black')# 保存图片    image.save(new_path_jpg + fr'\鱼骨图{name}_大图{b+1}.png')print('-----3、图卡制作成图片格式----------')import os
import random
from docx import Document
from docx.shared import Cm
from docx2pdf import convert
from PyPDF2 import PdfFileMergernew_folder = path + r'\零时文件夹'
os.makedirs(new_folder, exist_ok=True)image_files = [os.path.join(new_path, file) for file in os.listdir(new_path) if file.endswith('.png')]
# random.shuffle(image_files)grouped_files = [image_files[i:i + 6] for i in range(0, len(image_files), 6)]for group_index, group in enumerate(grouped_files):doc = Document(path + r'\鱼骨图题卡.docx')table = doc.tables[0]for cell_index, image_file in enumerate(group):cell = table.cell(int(cell_index / 2), cell_index % 2)cell_paragraph = cell.paragraphs[0]cell_paragraph.clear()run = cell_paragraph.add_run()run.add_picture(image_file, width=Cm(13.92), height=Cm(6.49))doc.save(os.path.join(new_folder, f'{group_index + 1:03d}.docx'))# pdf_output_path = path + fr'\\鱼骨图AAB({name})题卡{len(perms)}张_固定顺序.pdf'
pdf_output_path = path + fr'\\鱼骨图AAB({name})题卡{len(perms)}张_随机顺序.pdf'for docx_file in os.listdir(new_folder):if docx_file.endswith('.docx'):docx_path = os.path.join(new_folder, docx_file)convert(docx_path, docx_path.replace('.docx', '.pdf'))merger = PdfFileMerger()
for pdf_file in os.listdir(new_folder):if pdf_file.endswith('.pdf'):pdf_path = os.path.join(new_folder, pdf_file)merger.append(pdf_path)merger.write(pdf_output_path)
merger.close()import shutil,time
shutil.rmtree(new_folder)print('-----4、图卡制作成操作图格式----------')import os
import random
from docx import Document
from docx.shared import Cm
from docx2pdf import convert
from PyPDF2 import PdfFileMergernew_folder = path + r'\零时文件夹'
os.makedirs(new_folder, exist_ok=True)image_files = [os.path.join(new_path_jpg, file) for file in os.listdir(new_path_jpg) if file.endswith('.png')]
# random.shuffle(image_files)grouped_files = [image_files[i:i + 2] for i in range(0, len(image_files), 2)]for group_index, group in enumerate(grouped_files):doc = Document(path + r'\鱼骨图操作图.docx')table = doc.tables[0]for cell_index, image_file in enumerate(group):cell = table.cell(int(cell_index / 1), cell_index % 1)cell_paragraph = cell.paragraphs[0]cell_paragraph.clear()run = cell_paragraph.add_run()run.add_picture(image_file, width=Cm(21.62), height=Cm(9.7))doc.save(os.path.join(new_folder, f'{group_index + 1:03d}.docx'))# pdf_output_path = path + fr'\\鱼骨图AAB({name})操作卡2张_固定顺序.pdf'
pdf_output_path = path + fr'\\鱼骨图AAB({name})操作卡2张_随机顺序2.pdf'for docx_file in os.listdir(new_folder):if docx_file.endswith('.docx'):docx_path = os.path.join(new_folder, docx_file)convert(docx_path, docx_path.replace('.docx', '.pdf'))merger = PdfFileMerger()
for pdf_file in os.listdir(new_folder):if pdf_file.endswith('.pdf'):pdf_path = os.path.join(new_folder, pdf_file)merger.append(pdf_path)merger.write(pdf_output_path)
merger.close()
time.sleep(5)import shutil
shutil.rmtree(new_folder)
shutil.rmtree(new_path)
shutil.rmtree(new_path_jpg)

 

 

一共有两种抽取方式

第一种是固定抽取,从"红"开始选择

我默认“红橙黄绿蓝紫”为固定顺序,这里的颜色前面加了01、02,因为如果按照字母,blue排在最前面,而不是red,就会出现乱序。

8cf8c792e83f4ee68d63efc3464931af.png

742786ed4dfa4677b613ead7678cee96.png

第一根棒子都是“红色”,依次配对“橙黄绿蓝紫”

8299bf2d317140718e80ffe2afd1a0e8.png

 

最后一根棒子都是“紫色”,依次配对“红橙黄绿蓝”

fab865ca62fc4ee78c6b7d0c75566342.png

 

操作图

566557ea3aec411b9d7aefbf2a0a0a18.png

 

 第二种是随机抽取,打乱顺序,每次出现顺序都不同

0432717991924ed79c98f248f0536a08.png

我默认“红橙黄绿蓝紫”为固定顺序,这里的颜色前面加了01、02,因为如果按照字母,blue排在最前面,而不是red,就会出现乱序。

d8d8c2dbb5b34689b08219e6e3f232fc.png

 

 

第1次随机 001-006

c28c637e49af4e7586d633ebb258bf36.png

第2次随机 001-006

59893d39a7934f8fa1f963f212efb724.png

 

操作图

566557ea3aec411b9d7aefbf2a0a0a18.png

 

 

因为一共是6根棒子

有ABCDEF(1*6)、ABABAB(2*3)、ABCABC(3*2)、ABBABB((1+2)*2)、AABAAB ((2+1)*2)五种排序方式

 

 

 

 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com