A Python library for generating personalized QR codes
Project description
Cool QRCode
一个用于生成个性化二维码的Python库,支持自定义颜色、形状、Logo和蒙板效果。
特性
- 🎨 自定义颜色 - 支持命名颜色和十六进制颜色代码
- ⭐ 预设风格 - 内置8种精美配色方案
- 🔘 自定义形状 - 支持方形和圆形码点
- 🖼️ 添加Logo - 支持方形和圆形Logo
- 🎭 蒙板效果 - 添加半透明色彩蒙板
- 💫 万能API - 通过单一函数支持所有效果组合
- 🚸 学生友好 - 提供简单易用的中文API和教程
安装
pip install cool-qrcode
快速开始
基本使用
from cool_qrcode import make_cool_qrcode
# 最简单的用法
make_cool_qrcode("Hello, World!", filename="basic.png")
使用预设风格
# 使用海洋风格
make_cool_qrcode(
"Hello, Ocean!",
style="ocean",
filename="ocean_style.png"
)
圆形码点
# 使用圆形码点
make_cool_qrcode(
"Hello, Circle!",
dot_shape="circle",
fill_color="green",
back_color="white",
filename="circle_dots.png"
)
添加Logo
# 添加圆形Logo
make_cool_qrcode(
"Hello, Logo!",
logo_path="your_logo.png",
logo_circular=True,
filename="with_logo.png"
)
组合所有效果
# 组合多种效果
make_cool_qrcode(
"Hello, Cool QRCode!",
style="berry", # 使用预设风格
dot_shape="circle", # 圆形码点
logo_path="logo.png", # 添加Logo
logo_circular=True, # 圆形Logo
mask_color="purple", # 紫色蒙板
mask_opacity=0.15, # 透明度
size=600, # 大尺寸
filename="cool_qr.png"
)
文档
make_cool_qrcode() 万能API
make_cool_qrcode(
data, # 二维码内容
filename=None, # 保存文件名
size=500, # 图片大小
fill_color="black", # 前景色
back_color="white", # 背景色
style=None, # 预设风格
dot_shape="square", # 码点形状
logo_path=None, # Logo路径
logo_circular=True, # Logo是否为圆形
mask_color=None, # 蒙板颜色
mask_opacity=0.3 # 蒙板透明度
)
详细使用方法参见 API文档。
支持的颜色
支持多种命名颜色和十六进制颜色代码,包括:
- 基础颜色:red, green, blue, yellow, purple, orange...
- 常用颜色:aqua, fuchsia, lime, maroon, navy, olive...
- 扩展颜色:lightblue, darkgreen, lavender...
详细颜色列表参见 颜色参考。
预设风格
内置8种精美配色方案:
- ocean - 海洋风格(蓝色系)
- forest - 森林风格(绿色系)
- sunset - 日落风格(橙色系)
- berry - 浆果风格(紫色系)
- fire - 火焰风格(红色系)
- mint - 薄荷风格(青色系)
- chocolate - 巧克力风格(棕色系)
- night - 夜空风格(深蓝系)
示例
详细示例代码见 examples 目录。
许可证
本项目采用 MIT 许可证 - 详见 LICENSE 文件
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cool_qrcode-0.1.1.tar.gz
(60.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cool_qrcode-0.1.1.tar.gz.
File metadata
- Download URL: cool_qrcode-0.1.1.tar.gz
- Upload date:
- Size: 60.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5de8eae292bb542b709eb5038a530443a993bd153e682db327e5b544a08385a
|
|
| MD5 |
3b8d9adbe5edec90336e165ca7bc53ef
|
|
| BLAKE2b-256 |
4c3ac6c86cb0c2a4a72c9aafb6dc87230b75e3c30f48170292f5cbc7a9a35ff1
|
File details
Details for the file cool_qrcode-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cool_qrcode-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef4fea81fdc360c2b34dd3271a0113d4fdb54ecf67b3a9d836043c98d8835bf3
|
|
| MD5 |
be7ac829b1a403d39a925515453674da
|
|
| BLAKE2b-256 |
00dba37f11d44acffc567f523821cac6ac0cf87bba2af5c172f5036774b9aa90
|