跳转到内容

File:八數相對圖.svg

页面内容不支持其他语言。
维基文库,自由的图书馆

原始文件 (SVG文件,尺寸为300 × 300像素,文件大小:2 KB)

摘要

描述
中文:八數相對圖
日期
来源 自己的作品
作者 Zy26
import svgwrite
import math

# Constants
CONFIG = {
    'svg_file_path': '八數相對圖.svg',
    'circle_text_data': [
        {'angle': 0, 'main_text': "凶", 'sub_text': "火九"},
        {'angle': 45, 'main_text': "咎", 'sub_text': "金二"},
        {'angle': 90, 'main_text': "災", 'sub_text': "金七"},
        {'angle': 135, 'main_text': "悔", 'sub_text': "水六"},
        {'angle': 180, 'main_text': "吉", 'sub_text': "水一"},
        {'angle': -135, 'main_text': "休", 'sub_text': "木三"},
        {'angle': -90, 'main_text': "祥", 'sub_text': "木三"},
        {'angle': -45, 'main_text': "吝", 'sub_text': "火四"}
    ],
    'svg_side_length': 300,
    'main_circle_radius': 130,
    'text_circle_radius': 100,
    'font_size_main': 20,
    'font_size_sub': 10,
    'text_offset': 20,
    'stroke_color': "black",
    'fill_color': "none",
    'text_fill_color': "black",
    'text_anchor': "middle"
}

def add_circle(drawing, center, radius, stroke_color, fill_color):
    drawing.add(drawing.circle(center=(center, center), r=radius, stroke=stroke_color, fill=fill_color))

def add_text(drawing, center, text_data, text_circle_radius, font_size_main, font_size_sub, text_offset, text_fill_color, text_anchor):
    for data in text_data:
        angle = data['angle']
        rad = math.radians(angle)
        x = center + text_circle_radius * math.sin(rad)
        y = center - text_circle_radius * math.cos(rad)
        text_group = drawing.g(transform=f"rotate({angle}, {x}, {y})")
        text_group.add(drawing.text(data['main_text'], insert=(x, y), fill=text_fill_color, font_size=f"{font_size_main}px", text_anchor=text_anchor))
        text_group.add(drawing.text(data['sub_text'], insert=(x, y + text_offset), fill=text_fill_color, font_size=f"{font_size_sub}px", text_anchor=text_anchor))
        drawing.add(text_group)

def generate_svg(config):
    center = config['svg_side_length'] / 2
    drawing = svgwrite.Drawing(config['svg_file_path'], profile='tiny', size=(f"{config['svg_side_length']}px", f"{config['svg_side_length']}px"))
    add_circle(drawing, center, config['main_circle_radius'], config['stroke_color'], config['fill_color'])
    add_text(drawing, center, config['circle_text_data'], config['text_circle_radius'], config['font_size_main'], config['font_size_sub'], config['text_offset'], config['text_fill_color'], config['text_anchor'])
    drawing.save()

generate_svg(CONFIG)

许可协议

我,本作品著作权人,特此采用以下许可协议发表本作品:
Creative Commons CC-Zero 本作品采用知识共享CC0 1.0 通用公有领域贡献许可协议授权。
采用本宣告发表本作品的人,已在法律允许的范围内,通过在全世界放弃其对本作品拥有的著作权法规定的所有权利(包括所有相关权利),将本作品贡献至公有领域。您可以复制、修改、传播和表演本作品,将其用于商业目的,无需要求授权。

说明

添加一行文字以描述该文件所表现的内容
八數相對圖

此文件中描述的项目

描绘内容

image/svg+xml

文件历史

点击某个日期/时间查看对应时刻的文件。

日期/时间缩⁠略⁠图大小用户备注
当前2024年8月21日 (三) 02:392024年8月21日 (三) 02:39版本的缩略图300 × 300(2 KB)Zy26minor edit
2024年8月21日 (三) 02:212024年8月21日 (三) 02:21版本的缩略图300 × 300(2 KB)Zy26minor fix
2024年8月21日 (三) 01:472024年8月21日 (三) 01:47版本的缩略图300 × 300(2 KB)Zy26fix angle
2024年8月21日 (三) 00:342024年8月21日 (三) 00:34版本的缩略图300 × 300(2 KB)Zy26typo
2024年8月21日 (三) 00:022024年8月21日 (三) 00:02版本的缩略图300 × 300(2 KB)Zy26typo
2024年8月20日 (二) 23:432024年8月20日 (二) 23:43版本的缩略图300 × 300(2 KB)Zy26Uploaded own work with UploadWizard

以下页面使用本文件:

元数据