CrabNote螃蟹笔记

景淮:镜子画布小游戏

景淮:镜子画布小游戏

景淮:镜子画布小游戏 景淮:镜子画布小游戏 Modified March 2, 2024 Code block Markdown Copy Draw horizontal and vertical dashed lines for i in range(11): draw dashed line(draw, (i width / 10, 0), (i width / 10, height), 'black') draw dashed line(draw, (0, i height / 10), (width, i height / 10), 'black') Display the result combined image.show() Load the uploaded image uploaded img path = '/mnt/data/image.png' uploaded img = Image.open(uploaded img path) Convert the image to RGBA if it is not already in that mode if uploaded img.mode != 'RGBA': uploaded img = uploaded img.convert('RGBA') Get the right half of the image right half = uploaded img.crop((width // 2, 0, width, height)) We need to process the right half and change black lines to red For that, we will use a function that changes all pixels that are not white into red def change lines to red(img): Get the data of the image data = img.getdata() Change black (all non white since it's a line drawing) to red new data = [] for item in data: Change black to red if item[0] < 200 and item[1] < 200 and item[2] < 200: new data.append((255, 0, 0, item[3])) item[3] is the alpha channel else: new data.append(item) No change to white and other colors Update image data img.putdata(new data) return img Change the black lines to red on the right half red right half = change lines to red(right half) Create a new image to combine the original left half and the modified right half final img = Image.new('RGBA', uploaded img.size) final img.paste(uploaded img.crop((0, 0, width // 2, height)), (0, 0)) final img.paste(red right half, (width // 2, 0)) Display the result combined image.show() Code block Markdown Copy Draw horizontal and vertical dashed lines for i in range(11): draw dashed line(draw, (i width / 10, 0), (i width / 10, height), 'black') draw dashed line(draw, (0, i height / 10), (width, i height / 10), 'black') Display the result combined image.show() Load the uploaded image uploaded img path = '/mnt/data/image.png' uploaded img = Image.open(uploaded img path) Convert the image to RGBA if it is not already in that mode if uploaded img.mode != 'RGBA': uploaded img = uploaded img.convert('RGBA') Get the right half of the image right half = uploaded img.crop((width // 2, 0, width, height)) We need to process the right half and change black lines to red For that, we will use a function that changes all pixels that are not white into red def change lines to red(img): Get the data of the image data = img.getdata() Change black (all non white since it's a line drawing) to red new data = [] for item in data: Change black to red if item[0] < 200 and item[1] < 200 and item[2] < 200: new data.append((255, 0, 0, item[3])) item[3] is the alpha channel else: new data.append(item) No change to white and other colors Update image data img.putdata(new data) return img Change the black lines to red on the right half red right half = change lines to red(right half) Create a new image to combine the original left half and the modified right half final img = Image.new('RGBA', uploaded img.size) final img.paste(uploaded img.crop((0, 0, width // 2, height)), (0, 0)) final img.paste(red right half, (width // 2, 0)) Display the result combined image.show() 三)测试结果 1、原图 2、“橡皮擦”难度 3、“田字格"辅助线模式 4、“描红” 辅助线模式 四、GPTs 使用链接 一)测试链接 https://chat.openai.com/g/g KNNVk0KgA hai zi wang xi lie jing zi hua bu xiao you xi 二)效果展示 1、原图 2、“橡皮擦”难度 3、“田字格"辅助线模式 4、“描红” 辅助线模式 五、总结 这个文章的卡点被我单独拿出来了 准备之后单独做一篇内容来处理,主要是关于对简笔画上色的操作。敬请期待 好啦,写到这里我们今天的内容也结束啦,感谢大家的观看,也希望我的内容能够让大家喜欢,有所收获。感兴趣的小伙伴可以点个关注跟随我一起学习,观看更多往期文章,如果想要链接我,可以加我vx:jinghuai8092。 嘿,下次见,我是景淮,一个加拿大的程序员,沉迷 AI 不能自拔 景淮老师还有很多教程记录,欢迎来看看 景淮:镜子画布小游戏 景淮:彩色汉字小游戏 GPTs Action 实战 景淮:儿童汉语词典 GPTs Action 实战 景淮:制作成语小游戏 GPTs Action 实战 景淮:"记忆图卡" 小游戏 GPTs 实战 景淮:诗词大百科 GPT Action实战 景淮:制作 "数独游戏" 小游戏 GPTs Action 实战 景淮:漫画趣味高中大学时期对比图 GPTs 实战 景淮:情侣之间甜蜜时光记录小助手 GPT 辅助制作 景淮:金句明信片(壁纸) GPT 辅助制作 景淮:新春贺卡制作(中文版本) GPTs 实战 景淮:镜子画布小游戏 景淮:彩色汉字小游戏 GPTs Action 实战 景淮:儿童汉语词典 GPTs Action 实战 景淮:制作成语小游戏 GPTs Action 实战 景淮:"记忆图卡" 小游戏 GPTs 实战 景淮:诗词大百科 GPT Action实战 景淮:制作 "数独游戏" 小游戏 GPTs Action 实战 景淮:漫画趣味高中大学时期对比图 GPTs 实战 景淮:情侣之间甜蜜时光记录小助手 GPT 辅助制作 景淮:金句明信片(壁纸) GPT 辅助制作 景淮:新春贺卡制作(中文版本) GPTs 实战 景淮老师还有很多教程记录,欢迎来看看 景淮:镜子画布小游戏 景淮:镜子画布小游戏 景淮:彩色汉字小游戏 GPTs Action 实战 景淮:彩色汉字小游戏 GPTs Action 实战 景淮:儿童汉语词典 GPTs Action 实战 景淮:儿童汉语词典 GPTs Action 实战 景淮:制作成语小游戏 GPTs Action 实战 景淮:制作成语小游戏 GPTs Action 实战 景淮:"记忆图卡" 小游戏 GPTs 实战 景淮:"记忆图卡" 小游戏 GPTs 实战 景淮:诗词大百科 GPT Action实战 景淮:诗词大百科 GPT Action实战 景淮:制作 "数独游戏" 小游戏 GPTs Action 实战 景淮:制作 "数独游戏" 小游戏 GPTs Action 实战 景淮:漫画趣味高中大学时期对比图 GPTs 实战 景淮:漫画趣味高中大学时期对比图 GPTs 实战 景淮:情侣之间甜蜜时光记录小助手 GPT 辅助制作 景淮:情侣之间甜蜜时光记录小助手 GPT 辅助制作 景淮:金句明信片(壁纸) GPT 辅助制作 景淮:金句明信片(壁纸) GPT 辅助制作 景淮:新春贺卡制作(中文版本) GPTs 实战 景淮:新春贺卡制作(中文版本) GPTs 实战 📗 嘿,大家好呀,我是景淮,一个加拿大的程序员,沉迷 AI 不能自拔中 公众号: 景淮AI探索之旅 嘿,大家好呀,我是景淮,一个加拿大的程序员,沉迷 AI 不能自拔中 公众号: 景淮AI探索之旅 可以先尝试一下 https://chat.openai.com/g/g KNNVk0KgA hai zi wang xi lie jing zi hua bu xiao you xi 下面是产出过程 首先感谢小伙伴们的对我所立下的 Flag 的支持,才开始“孩子王”系列的第一篇,就已经很多小伙伴们开始催更后面的内容了 也欢迎大家催更和监督,尽快完成我立下的 Flag。 今天的灵感来源其实很奇妙,最最开始是因为小外甥练字,要我帮忙打印字帖,打印字帖的时候很无聊,就开始景淮式的胡思乱想了。这边略过胡思乱想的过程...(因为实在是我也想不起来这个思考的逻辑了...) 最后也就有了今天这篇的内容 今天是我要更新孩子王系列内容的第 2 篇 GPT 制作 "镜子画布"小游戏 本文会根据以下内容顺序进行: • 需求分析 • 分步实现需求 • 提示词编写测试 • GPTs 使用链接 • 总结 一、需求分析 一)什么是"镜子画布"小游戏 "镜子画布"小游戏也是教育类小游戏的一种,旨在帮助孩子理解和掌握对称这个概念,在这个游戏中孩子会被给予一半的图形,然后被要求完成另一半,以形成一个完全对称的图形。这种游戏可以帮助孩子们理解对称性,提高他们的观察力和绘图技巧。 下面是一些对称图小游戏的图片示例: 二)内容需求 其实在上一篇的时候,就有好朋友针对内容给我提出了宝贵的意见,就是能不能分成不同年龄、等级。因为这样可以针对孩子不同的阶段给出不同的难易度玩法。不会让大一点的孩子觉得过于简单,也不会让小一点的孩子觉得内容难以理解。所以在这次的游戏设计中加入“选择难易度等级”这个概念。(同时也期待大家给出更多的意见,完善内容) 1、图片的生成 当用户选择主题后,根据主题画出相关内容。 2、图片的处理 当我们获得图片后,我们要对图片进行以下步骤的处理。 1. 对图片以中心点进行分割(对称轴) 2. 对图片右侧的内容进行“橡皮擦”处理,这边其实也可以分为两种难易程度 a. 第一种,进行完全“擦掉”处理 b. 第二种,跟上述图片一样,给出辅助线,帮助完成绘画 c. 第三种,像我们学习写字的字帖一样,对图片中的线条进行“做浅”,这样更方便孩子进行绘画和练习 a. 第一种,进行完全“擦掉”处理 b. 第二种,跟上述图片一样,给出辅助线,帮助完成绘画 c. 第三种,像我们学习写字的字帖一样,对图片中的线条进行“做浅”,这样更方便孩子进行绘画和练习 3、用户输入 基本上输入这块,基于上述的设定,分为以下三部分内容: a. 输入一个主题(关键词)或随机生成 10 个主题(关键词) b. 输入所选等级(简单,中等,困难) c. 输入描图的辅助线等级(无辅助线,"田字格" 辅助线,“描红” 辅助线) a. 输入一个主题(关键词)或随机生成 10 个主题(关键词) b. 输入所选等级(简单,中等,困难) c. 输入描图的辅助线等级(无辅助线,"田字格" 辅助线,“描红” 辅助线) 三)需求整合 二、分部需求实现 一)图片生成 提示词 🎁 使用简笔画的方式帮我画一张机器人的图片,画风可爱一些,去掉所有辅助线,要求只有唯一的一个主人公,同时左右对称结构,线条少一些简单点。 使用简笔画的方式帮我画一张机器人的图片,画风可爱一些,去掉所有辅助线,要求只有唯一的一个主人公,同时左右对称结构,线条少一些简单点。 生成结果 提取绘画提示词 ⚽ A cute, simple line drawing of a symmetrical [主人公]. The [主人公] is designed to be the only character in the image, with a focus on minimalistic lines and a symmetric structure. All auxiliary lines are removed to emphasize the simplicity of the drawing. A cute, simple line drawing of a symmetrical [主人公]. The [主人公] is designed to be the only character in the image, with a focus on minimalistic lines and a symmetric structure. All auxiliary lines are removed to emphasize the simplicity of the drawing. 测试:一只小猫 二)图片处理 1、“橡皮擦”难度 提示词 ❤️ 请你使用python。按以下步骤帮我处理上面的图片 1. 以中轴线为基础,把图片进行裁剪。 2. 图片左边保持原样不动,图片右边增加一个长宽与图片左边完全相同的空白图片,且背景色一致。 3. 把生成的结果展示给用户 请你使用python。按以下步骤帮我处理上面的图片 1. 以中轴线为基础,把图片进行裁剪。 2. 图片左边保持原样不动,图片右边增加一个长宽与图片左边完全相同的空白图片,且背景色一致。 3. 把生成的结果展示给用户 生成结果 2、“田字格"辅助线模式 提示词 ⛱️ 请你使用python。按以下步骤帮我处理上面的图片 1. 以中轴线为基础,把图片进行裁剪。 2. 图片左边保持原样不动,图片右边增加一个长宽与图片左边完全相同的空白图片,且背景色一致。 3.针对新生成的整张图,加入辅助线(虚线),同时水平方向 11 条,竖直方向 11 条,要确保每条辅助线之间的距离相同。 4. 把生成的结果展示给用户 请你使用python。按以下步骤帮我处理上面的图片 1. 以中轴线为基础,把图片进行裁剪。 2. 图片左边保持原样不动,图片右边增加一个长宽与图片左边完全相同的空白图片,且背景色一致。 3.针对新生成的整张图,加入辅助线(虚线),同时水平方向 11 条,竖直方向 11 条,要确保每条辅助线之间的距离相同。 4. 把生成的结果展示给用户 生成效果 3、 “描红” 辅助线模式 提示词 三、提示词编写测试 一)初版提示词 Load the uploaded image uploaded img path = '/mnt/data/image.png' uploaded img = Image.open(uploaded img path) Convert the image to RGBA if it is not already in that mode if uploaded img.mode != 'RGBA': uploaded img = uploaded img.convert('RGBA') Get the right half of the image right half = uploaded img.crop((width // 2, 0, width, height)) We need to process the right half and change black lines to red For that, we will use a function that changes all pixels that are not white into red def change lines to red(img): Get the data of the image data = img.getdata() Change black (all non white since it's a line drawing) to red new data = [] for item in data: Change black to red if item[0] < 200 and item[1] < 200 and item[2] < 200: new data.append((255, 0, 0, item[3])) item[3] is the alpha channel else: new data.append(item) No change to white and other colors Update image data img.putdata(new data) return img Change the black lines to red on the right half red right half = change lines to red(right half) Create a new image to combine the original left half and the modified right half final img = Image.new('RGBA', uploaded img.size) final img.paste(uploaded img.crop((0, 0, width // 2, height)), (0, 0)) final img.paste(red right half, (width // 2, 0)) Save the final image final img path = '/mnt/data/image with red right half.png' ``` 二) 迭代后的提示词