你好

用户头像
来自佳木斯大学-陈宇发布于:2024-12-02 11:20:40
#include(graphics. h #include (conio.h #include(time. h #include (math. h #include(stdlib.h 7 CO , vstruct Point{ double x, y; COLORREF color; 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 сОLОRRЕР сооrs[256] ={ RСВ (255, 138, 180), RСВ (252, 145, 196), RСВ (255, 144, 194) RGB (255, 144, 194), RGB (255, 143, 195), RGB (255, 140, 190), RGB (255, 142, 193)}: const int xScreen =1200; const int yScreen= 800; const double PI=3. 1426535159 const double e= 2. 71828 const double averag_distance=0. 162; const int quantity-506 const int circles=210: const int frames=20; Pointorigin points [quantityl: Point points[circles* quantity]; IMAGE images [frames]: double sçreen_x(double x) +xScreen/ 2; return X; vdouble sçreen_y (double y) y--y+ yScreen/2; return y: vint creat_random (int x1, int x2) if (x2> x1) return randO% (x2- x1+1)+x1; Vvoid creat_data( # int index=0; double x1=0, yl=0, x2=0,y2=0; for (double radian =0. 1; radian (-2* PI; radian +=0. 005)import random from math import sin, cos, pi, log from tkinter import * CANVAS_WIDTH = 640 # 画布的宽 CANVAS_HEIGHT = 480 # 画布的高 CANVAS_CENTER_X = CANVAS_WIDTH / 2 # 画布中心的X轴坐标 CANVAS_CENTER_Y = CANVAS_HEIGHT / 2 # 画布中心的Y轴坐标 IMAGE_ENLARGE = 11 # 放大比例 HEART_COLOR = "#ff2121" # 心的颜色,这个是中国红 def heart_function(t, shrink_ratio: float = IMAGE_ENLARGE): """ “爱心函数生成器” :param shrink_ratio: 放大比例 :param t: 参数 :return: 坐标 """ # 基础函数 x = 16 * (sin(t) ** 3) y = -(13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)) # 放大 x *= shrink_ratio y *= shrink_ratio # 移到画布中央 x += CANVAS_CENTER_X y += CANVAS_CENTER_Y return int(x), int(y) def scatter_inside(x, y, beta=0.15): """ 随机内部扩散 :param x: 原x :param y: 原y :param beta: 强度 :return: 新坐标 """ ratio_x = - beta * log(random.random()) ratio_y = - beta * log(random.random()) dx = ratio_x * (x - CANVAS_CENTER_X) dy = ratio_y * (y - CANVAS_CENTER_Y) return x - dx, y - dy def shrink(x, y, ratio): """ 抖动 :param x: 原x :param y: 原y :param ratio: 比例 :return: 新坐标 """ force = -1 / (((x - CANVAS_CENTER_X) ** 2 + (y - CANVAS_CENTER_Y) ** 2) ** 0.6) # 这个参数... dx = ratio * force * (x - CANVAS_CENTER_X) dy = ratio * force * (y - CANVAS_CENTER_Y) return x - dx, y - dy#include(graphics. h #include (conio.h #include(time. h #include (math. h #include(stdlib.h 7 CO , vstruct Point{ double x, y; COLORREF color; 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 сОLОRRЕР сооrs[256] ={ RСВ (255, 138, 180), RСВ (252, 145, 196), RСВ (255, 144, 194) RGB (255, 144, 194), RGB (255, 143, 195), RGB (255, 140, 190), RGB (255, 142, 193)}: const int xScreen =1200; const int yScreen= 800; const double PI=3. 1426535159 const double e= 2. 71828 const double averag_distance=0. 162; const int quantity-506 const int circles=210: const int frames=20; Pointorigin points [quantityl: Point points[circles* quantity]; IMAGE images [frames]: double sçreen_x(double x) +xScreen/ 2; return X; vdouble sçreen_y (double y) y--y+ yScreen/2; return y: vint creat_random (int x1, int x2) if (x2> x1) return randO% (x2- x1+1)+x1; Vvoid creat_data( # int index=0; double x1=0, yl=0, x2=0,y2=0; for (double radian =0. 1; radian (-2* PI; radian +=0. 005)#include(graphics. h #include (conio.h #include(time. h #include (math. h #include(stdlib.himport random from math import sin, cos, pi, log from tkinter import * CANVAS_WIDTH = 640 # 画布的宽 CANVAS_HEIGHT = 480 # 画布的高 CANVAS_CENTER_X = CANVAS_WIDTH / 2 # 画布中心的X轴坐标 CANVAS_CENTER_Y = CANVAS_HEIGHT / 2 # 画布中心的Y轴坐标 IMAGE_ENLARGE = 11 # 放大比例 HEART_COLOR = "#ff2121" # 心的颜色,这个是中国红 def heart_function(t, shrink_ratio: float = IMAGE_ENLARGE): """ “爱心函数生成器” :param shrink_ratio: 放大比例 :param t: 参数 :return: 坐标 """ # 基础函数 x = 16 * (sin(t) ** 3) y = -(13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)) # 放大 x *= shrink_ratio y *= shrink_ratio # 移到画布中央 x += CANVAS_CENTER_X y += CANVAS_CENTER_Y return int(x), int(y) def scatter_inside(x, y, beta=0.15): """ 随机内部扩散 :param x: 原x :param y: 原y :param beta: 强度 :return: 新坐标 """ ratio_x = - beta * log(random.random()) ratio_y = - beta * log(random.random()) dx = ratio_x * (x - CANVAS_CENTER_X) dy = ratio_y * (y - CANVAS_CENTER_Y) return x - dx, y - dy def shrink(x, y, ratio): """ 抖动 :param x: 原x :param y: 原y :param ratio: 比例 :return: 新坐标 """ force = -1 / (((x - CANVAS_CENTER_X) ** 2 + (y - CANVAS_CENTER_Y) ** 2) ** 0.6) # 这个参数... dx = ratio * force * (x - CANVAS_CENTER_X) dy = ratio * force * (y - CANVAS_CENTER_Y) return x - dx, y - dy
点赞 (1) 回复
发布回复
点击图片