【教学类-50-10】20240505“数一数”图片样式08:数一数(几何图案——三原色纯色重叠)

作品展示

背景需求:

幼儿操作中,选择“三原色图片(红柱、黄柱)“选择“透透明红黄蓝图片(绿柱、蓝柱)”的孩子更多。

图22-1  幼儿选择4款学具次数的直方图

分析原因:

(1)深色与浅色

从视觉角度来看,星1星2的图片都是三原色,饱和度高;星3星4图案相交重叠而降低了透明度,颜色比较浅。中班幼儿普遍喜欢鲜艳的色彩,因此优先选择鲜亮的颜色。

处理方式:

(1)保留鲜艳颜色——提升点数难度

“图形相交”时,将透明度从0.3改成1.0,也能实现图案遮挡的效果,从而提升挑战性,鼓励一些幼儿将根据图形的一部分外形,推测图形的全貌。

有趣的“图形遮挡”现象(因为加了黑色边框,所以看起来清晰多了)

【教学类-50-07】20240502“数一数”图片样式07:数一数(几何图案——图形有黑色外框线)-CSDN博客文章浏览阅读1k次,点赞29次,收藏15次。【教学类-50-07】20240502“数一数”图片样式07:数一数(几何图案——图形有黑色外框线)https://blog.csdn.net/reasonsummer/article/details/138389938

代码展示

'''
02数一数图形(都是一个方向三角形)边框内+图案重叠(纯色遮挡有框)
作者:AI对话大师、阿夏
时间:2024年4月28日 20:00
'''


import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
import os
import random
import time
from shapely.geometry import Polygon
from shapely.ops import cascaded_union

c = int(input('画布大小(15)\n'))
num=int(input('多少张\n'))
alp=1.0
# float(input('透明度(1.0=分开纯色)\n'))

# 创建目录
output_dir = r'C:\Users\jg2yXRZ\OneDrive\桌面\数一数2\02几何框内连接'
end=output_dir+r'\01纯色遮挡有框线'
os.makedirs(output_dir, exist_ok=True)
os.makedirs(end, exist_ok=True)



for i in range(num):
    # 创建画布
    fig, ax = plt.subplots(figsize=(c, c))
    ax.set_xlim([0, c])
    ax.set_ylim([0, c])

    # 随机几个图形
    num_triangles = random.randint(1, 5)
    num_square = random.randint(1, 5)
    num_cicle = random.randint(1, 5)
    num_ellipse = random.randint(1, 5)
    num_rectangle = random.randint(1, 5)

    colors = ['red', 'yellow', 'blue']
    shapes = []
    # 直角三角形
    # for _ in range(num_triangles):
    #     while True:
    #         # 随机生成等腰直角三角形的顶点坐标
    #         base_point = np.random.rand(2) * c
    #         side_length = np.random.rand() * 2 + 1

    #         # 计算等腰直角三角形的顶点坐标
    #         top_point = base_point + np.array([side_length, 0])
    #         height_point = base_point + np.array([0, side_length])

    #         # 检查三角形是否在画布内部
    #         if np.all(base_point >= 0) and np.all(top_point <= c) and np.all(height_point <= c):
    #             break
        
    #     # 随机选择颜色
    #     color = np.random.choice(colors)

    #     # 创建并填充等腰直角三角形
    #     triangle_vertices = np.array([base_point, top_point, height_point])
    #     triangle = patches.Polygon(triangle_vertices, closed=True, alpha=alp, facecolor=color,edgecolor='black')
    #     ax.add_patch(triangle)
   
   
    # # 随机生成多个等边三角形
    import math

    for _ in range(num_triangles):
        while True:
            # 随机生成等边三角形的顶点坐标
            base_point = np.random.rand(2) * c
            side_length = np.random.rand() * 2 + 1

            # 计算等边三角形的顶点坐标
            height = side_length * math.sqrt(3) / 2
            top_point = base_point + np.array([side_length / 2, height])
            left_point = base_point + np.array([0, 0])
            right_point = base_point + np.array([side_length, 0])

            # 检查三角形是否在画布内部
            triangle = Polygon([left_point, right_point, top_point])
            if np.all(base_point >= 0) and np.all(top_point <= c) and \
                np.all(left_point >= 0) and np.all(right_point <= c) and \
                    not any(shape.intersects(triangle) for shape in shapes):
                break

        # 随机选择颜色
        color = np.random.choice(colors)

        # 创建并填充等边三角形
        triangle_vertices = np.array([left_point, right_point, top_point])
        triangle = Polygon(triangle_vertices)
        triangle_patch = patches.Polygon(triangle_vertices, closed=True, alpha=alp, facecolor=color,edgecolor='black')
        ax.add_patch(triangle_patch)
        shapes.append(triangle)

    # 随机生成正方形
    for _ in range(num_square):
        while True:
            # 随机生成正方形的中心点坐标
            center = np.random.rand(2) * c

            # 随机生成正方形的边长
            side_length = np.random.rand() * 2 + 1

            # 检查正方形是否在画布内部
            if np.all(center - side_length/2 >= 0) and np.all(center + side_length/2 <= c):
                break

        # 随机选择颜色
        color = np.random.choice(colors)

        # 创建并填充正方形
        square = patches.Rectangle((center[0] - side_length/2, center[1] - side_length/2), side_length, side_length, alpha=alp, facecolor=color,edgecolor='black')
        ax.add_patch(square)

    # 随机生成圆形
    for _ in range(num_cicle):
        while True:
            # 随机生成圆形的中心点坐标
            center = np.random.rand(2) * c

            # 随机生成圆形的半径
            radius = np.random.rand() * 2 + 1

            # 检查圆形是否在画布内部
            if np.all(center - radius >= 0) and np.all(center + radius <= c):
                break

        # 随机选择颜色
        color = np.random.choice(colors)

        # 创建并填充圆形
        circle = patches.Circle(center, radius, alpha=alp, facecolor=color,edgecolor='black')
        ax.add_patch(circle)

    #  # 随机生成椭圆形
    # for _ in range(num_ellipse):
    #     while True:
    #         # 随机生成椭圆形的中心点坐标
    #         center = np.random.rand(2) * c

    #         # 随机生成椭圆形的长轴和短轴
    #         major_axis = np.random.rand() * 2 + 1
    #         minor_axis = np.random.rand() * 2 + 1

    #         # 检查椭圆形是否在画布内部
    #         ellipse_vertices = []
    #         num_points = 100
    #         angle = np.linspace(0, 2 * np.pi, num_points)
    #         for a in angle:
    #             x = center[0] + major_axis / 2 * np.cos(a)
    #             y = center[1] + minor_axis / 2 * np.sin(a)
    #             ellipse_vertices.append([x, y])
    #         ellipse = Polygon(ellipse_vertices)
    #         if np.all(center - np.array([major_axis, minor_axis]) / 2 >= 0) and np.all(
    #                 center + np.array([major_axis, minor_axis]) / 2 <= c) and not any(
    #             shape.intersects(ellipse) for shape in shapes):
    #             break

    #     # 随机选择颜色
    #     color = np.random.choice(colors)

    #     # 创建并填充椭圆形
    #     ellipse_patch = patches.Ellipse((center[0], center[1]), major_axis, minor_axis, alpha=alp, facecolor=color,edgecolor='black')
    #     ax.add_patch(ellipse_patch)
    #     shapes.append(ellipse)
      # # 随机生成椭圆形水平的垂直的(90和180)
#     import random

    for _ in range(num_ellipse):
        while True:
            # 随机生成椭圆形的中心点坐标
            center = np.random.rand(2) * c

            # 随机生成椭圆形的长轴和短轴
            major_axis = np.random.rand() * 2 + 1
            minor_axis = major_axis / 2  # 将短轴设为长轴的一半,以满足2:1的长宽比

            # 随机选择椭圆形的旋转角度(90度或180度)
            angle = np.random.choice([np.pi / 2, np.pi])

            # 检查椭圆形是否在画布内部
            ellipse_vertices = []
            num_points = 100
            angle_points = np.linspace(0, 2 * np.pi, num_points)
            for a in angle_points:
                x = center[0] + major_axis / 2 * np.cos(a) * np.cos(angle) - minor_axis / 2 * np.sin(a) * np.sin(angle)
                y = center[1] + major_axis / 2 * np.cos(a) * np.sin(angle) + minor_axis / 2 * np.sin(a) * np.cos(angle)
                ellipse_vertices.append([x, y])
            ellipse = Polygon(ellipse_vertices)
            if np.all(center - np.array([major_axis, minor_axis]) / 2 >= 0) and np.all(
                    center + np.array([major_axis, minor_axis]) / 2 <= c) and not any(
                shape.intersects(ellipse) for shape in shapes):
                break

        # 随机选择颜色
        color = np.random.choice(colors)

        # 创建并填充椭圆形
        ellipse_patch = patches.Ellipse((center[0], center[1]), major_axis, minor_axis, angle=np.rad2deg(angle), alpha=alp,
                                        facecolor=color,edgecolor='black')
        ax.add_patch(ellipse_patch)
        shapes.append(ellipse)
    # # 随机生成长方形
    # for _ in range(num_rectangle):
    #     while True:
    #         # 随机生成长方形的中心点坐标
    #         center = np.random.rand(2) * c

    #         # 随机生成长方形的长和宽
    #         width = np.random.rand() * 2 + 1
    #         height = np.random.rand() * 2 + 1

    #         # 检查长方形是否在画布内部
    #         rectangle = Polygon([(center[0] - width / 2, center[1] - height / 2),
    #                              (center[0] + width / 2, center[1] - height / 2),
    #                              (center[0] + width / 2, center[1] + height / 2),
    #                              (center[0] - width / 2, center[1] + height / 2)])
    #         if np.all(center - np.array([width, height]) / 2 >= 0) and np.all(
    #                 center + np.array([width, height]) / 2 <= c) and not any(
    #             shape.intersects(rectangle) for shape in shapes):
    #             break

    #     # 随机选择颜色
    #     color = np.random.choice(colors)

    #     # 创建并填充长方形
    #     rectangle_patch = patches.Rectangle((center[0] - width / 2, center[1] - height / 2), width, height,
    #                                         alpha=alp, facecolor=color,edgecolor='black')
    #     ax.add_patch(rectangle_patch)
    #     shapes.append(rectangle)

    # 隐藏坐标轴
    ax.axis('off')

    # 保存图形
    output_path = os.path.join(end, f'{i:02d}.png')
    plt.savefig(output_path, dpi=200, bbox_inches='tight')

    # 关闭画布
    plt.close(fig)

    # 暂停3秒
    time.sleep(3)

因为重叠辨识有难度,所以只做了4张。

第二次“数一数2.0”测试时,发现四张“遮挡”都被选了

一方面可能是图片数量少(4张),还可能它排在“第1关分散几何点数”后面,幼儿选择它进行“跳一跳”挑战。

感悟:

生成代码在手,再生成20份!

随机数量、随机重叠,充满挑战和乐趣!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿夏reasonsummer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值