@ -0,0 +1,49 @@
|
|||||||
|
# FH的python代码
|
||||||
|
# 文本分析和图像识别
|
||||||
|
# 开发时间 2023/7/17 17:07
|
||||||
|
import tkinter as tk
|
||||||
|
import math
|
||||||
|
|
||||||
|
root = tk.Tk()
|
||||||
|
cv_small = tk.Canvas(root, width=220, height=180)
|
||||||
|
cv_small.pack()
|
||||||
|
|
||||||
|
cv_small.delete("all") # 清除画布
|
||||||
|
cv_small.create_line(50, 30, 110, 90, fill='red', width=2) # 左臂
|
||||||
|
cv_small.create_line(170, 30, 110, 90, fill='red', width=2) # 右臂
|
||||||
|
cv_small.create_line(110, 160, 110, 90, fill='red', width=2) # 中心线
|
||||||
|
|
||||||
|
root.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
def Y_tree(depth, percent, left_angle, right_angle, start_point, angle, length, canvas):
|
||||||
|
if depth == 0:
|
||||||
|
return
|
||||||
|
end_point = (start_point[0] + length * math.cos(math.radians(angle)),
|
||||||
|
start_point[1] - length * math.sin(math.radians(angle)))
|
||||||
|
canvas.create_line(start_point, end_point, fill='LightBlue4', width=2)
|
||||||
|
# canvas.update()
|
||||||
|
# canvas.after(1)
|
||||||
|
Y_tree(depth - 1, percent, left_angle, right_angle, end_point, angle + right_angle, length * percent,
|
||||||
|
canvas) # 画右枝
|
||||||
|
Y_tree(depth - 1, percent, left_angle, right_angle, end_point, angle - left_angle, length * percent,
|
||||||
|
canvas) # 画左枝
|
||||||
|
# print(start_point,end_point)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
root = tk.Tk()
|
||||||
|
canvas = tk.Canvas(root, width=1200, height=1000)
|
||||||
|
canvas.pack()
|
||||||
|
|
||||||
|
start_point = (300, 600)
|
||||||
|
angle = 45
|
||||||
|
length = 200
|
||||||
|
depth = 12
|
||||||
|
percent = 0.7
|
||||||
|
left_angle = 30
|
||||||
|
right_angle = 30
|
||||||
|
|
||||||
|
Y_tree(depth, percent, left_angle, right_angle, start_point, angle, length, canvas)
|
||||||
|
|
||||||
|
root.mainloop()
|
@ -0,0 +1,37 @@
|
|||||||
|
import math
|
||||||
|
from time import sleep
|
||||||
|
import tkinter as tk
|
||||||
|
root = tk.Tk()
|
||||||
|
|
||||||
|
def Y_pattern():
|
||||||
|
canvas.delete("all") # 清除画布
|
||||||
|
canvas.create_line(20, 30, 80, 90, fill='red', width=2) # 左臂
|
||||||
|
canvas.create_line(140, 30, 80, 90, fill='red', width=2) # 右臂
|
||||||
|
canvas.create_line(80, 160, 80, 90, fill='red', width=2) # 中心线
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def Y_tree(depth, percent, left_angle, right_angle, start_point, angle, length, canvas):
|
||||||
|
if depth == 0:
|
||||||
|
return
|
||||||
|
end_point = (start_point[0] + length * math.cos(math.radians(angle)),
|
||||||
|
start_point[1] - length * math.sin(math.radians(angle)))
|
||||||
|
canvas.create_line(start_point, end_point, width=2)
|
||||||
|
Y_tree(depth - 1, percent, left_angle, right_angle, end_point, angle + right_angle, length * percent,
|
||||||
|
canvas) # 画右枝
|
||||||
|
Y_tree(depth - 1, percent, left_angle, right_angle, end_point, angle - left_angle, length * percent,
|
||||||
|
canvas) # 画左枝
|
||||||
|
canvas.update()
|
||||||
|
sleep(0.001)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
canvas = tk.Canvas(root, width=1200, height=1000)
|
||||||
|
canvas.pack()
|
||||||
|
finishLevel = 10
|
||||||
|
treePercent = 0.7
|
||||||
|
leftAngle = 60
|
||||||
|
rightAngle = 60
|
||||||
|
initPoint = (520, 600)
|
||||||
|
initAngle = 90
|
||||||
|
initLong = 160
|
||||||
|
Y_tree(finishLevel, treePercent, leftAngle,rightAngle,initPoint,initAngle,initLong,canvas)
|
@ -0,0 +1,57 @@
|
|||||||
|
import pymysql
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
|
conn = pymysql.connect(user="root", password="123123", database="tree",
|
||||||
|
host="127.0.0.1", port=3306)
|
||||||
|
class DbUtil():
|
||||||
|
@staticmethod
|
||||||
|
def insert_to_fractal(name, e_name, basic_pattern, function_code, vars):
|
||||||
|
sql = """
|
||||||
|
insert into fractal(name, e_name, basic_pattern, function_code, vars) values (%s, %s, %s, %s, %s)
|
||||||
|
"""
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute(sql, (name, e_name, basic_pattern, function_code, vars))
|
||||||
|
conn.commit()
|
||||||
|
id = cursor.lastrowid
|
||||||
|
return id
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_to_fractal(fractal_id, name, e_name, basic_pattern, function_code, vars):
|
||||||
|
sql = """
|
||||||
|
update fractal set name=%s, e_name=%s, basic_pattern=%s, function_code=%s, vars=%s where id=%s
|
||||||
|
"""
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute(sql, (name, e_name, basic_pattern, function_code, vars, fractal_id))
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def insert_to_var(name, value, comment, fractal_id):
|
||||||
|
sql = f"insert into fractal_var values ('{name}', '{value}', '{comment}', {fractal_id})"
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute(sql)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete_fractal(id):
|
||||||
|
conn.cursor().execute(f"delete from fractal_var where fractal_id={id}")
|
||||||
|
conn.commit()
|
||||||
|
conn.cursor().execute(f"delete from fractal where id={id}")
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def execute(sql):
|
||||||
|
return pd.read_sql(sql, con=conn)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update(sql):
|
||||||
|
conn.cursor().execute(sql)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def query_fractal_by_id(id):
|
||||||
|
return pd.read_sql("select * from fractal where id={}".format(id), con=conn)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def query_fractal_var_by_id(id):
|
||||||
|
return pd.read_sql("select * from fractal_var where fractal_id={}".format(id), con=conn)
|
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 22 KiB |
@ -0,0 +1,14 @@
|
|||||||
|
function_string = """
|
||||||
|
def recursive_function(parameter):
|
||||||
|
if parameter <= 0:
|
||||||
|
return
|
||||||
|
print(parameter)
|
||||||
|
recursive_function(parameter - 1)
|
||||||
|
recursive_function(parameter)
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 定义参数字典
|
||||||
|
params = {'parameter': 5}
|
||||||
|
|
||||||
|
# 使用exec()执行函数字符串
|
||||||
|
exec(function_string, params)
|
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 615 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 664 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 115 KiB |
After Width: | Height: | Size: 218 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 726 B |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 31 KiB |