Skip to content

Commit 0c2de5d

Browse files
committed
初始化拼豆图纸计算库
0 parents  commit 0c2de5d

80 files changed

Lines changed: 64713 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.py text eol=lf
2+
*.md text eol=lf
3+
*.rst text eol=lf
4+
*.txt text eol=lf
5+
*.yml text eol=lf
6+
*.yaml text eol=lf
7+
*.json text eol=lf

.github/workflows/badge.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Badge Creation
2+
3+
on:
4+
push:
5+
branches: [ main, "badge/*", "doc/*" ]
6+
7+
jobs:
8+
update-badges:
9+
name: Update Badges
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 20
16+
submodules: true
17+
- name: Download cloc
18+
run: |
19+
sudo apt-get update -y
20+
sudo apt-get install -y cloc
21+
- name: Get the Numbers
22+
run: |
23+
cloc .
24+
echo "CODE_LINES=$(./cloc.sh --loc)" >> $GITHUB_ENV
25+
echo "COMMENT_LINES=$(./cloc.sh --percentage)%" >> $GITHUB_ENV
26+
- name: Create Lines-of-Code-Badge
27+
uses: schneegans/dynamic-badges-action@v1.7.0
28+
with:
29+
auth: ${{ secrets.GIST_TOKEN }}
30+
gistID: ${{ secrets.GIST_BADGE_ID }}
31+
filename: pypindou-loc.json
32+
label: Lines of Code
33+
message: ${{ env.CODE_LINES }}
34+
color: lightgrey
35+
- name: Create Comments-Badge
36+
uses: schneegans/dynamic-badges-action@v1.7.0
37+
with:
38+
auth: ${{ secrets.GIST_TOKEN }}
39+
gistID: ${{ secrets.GIST_BADGE_ID }}
40+
filename: pypindou-comments.json
41+
label: Comments
42+
message: ${{ env.COMMENT_LINES }}
43+
color: green

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Package Release
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
release:
9+
name: Publish to official pypi
10+
runs-on: ubuntu-latest
11+
if: ${{ github.repository == 'hansbug/pypindou' }}
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 20
17+
submodules: true
18+
- name: Set up python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r requirements-test.txt
26+
pip install -r requirements-build.txt
27+
- name: Build packages
28+
run: make package
29+
- name: Publish distribution to real PyPI
30+
uses: pypa/gh-action-pypi-publish@v1.13.0
31+
with:
32+
password: ${{ secrets.PYPI_PASSWORD }}
33+
- name: Upload distributions to release
34+
uses: svenstaro/upload-release-action@v2
35+
with:
36+
repo_token: ${{ secrets.GITHUB_TOKEN }}
37+
file: dist/*
38+
tag: ${{ github.ref }}
39+
overwrite: true
40+
file_glob: true

.github/workflows/test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Code Test
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
unittest:
8+
name: Code test
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os:
14+
- ubuntu-latest
15+
- windows-latest
16+
- macos-latest
17+
python-version:
18+
- "3.10"
19+
- "3.11"
20+
- "3.12"
21+
- "3.13"
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 20
28+
submodules: true
29+
- name: Set up python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- name: Install dependencies
34+
shell: bash
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install -r requirements-test.txt
38+
- name: Test the basic environment
39+
shell: bash
40+
run: |
41+
python -V
42+
pip --version
43+
make resource
44+
- name: Run unittest
45+
shell: bash
46+
env:
47+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
48+
run: |
49+
make unittest
50+
- name: Upload coverage to Codecov
51+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' }}
52+
uses: codecov/codecov-action@v5
53+
with:
54+
token: ${{ secrets.CODECOV_TOKEN }}
55+
files: ./coverage.xml

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/.coverage
2+
/.pytest_cache/
3+
/.ruff_cache/
4+
/build/
5+
/dist/
6+
/*.egg-info/
7+
/coverage.xml
8+
/junit.xml
9+
/docs/build/
10+
__pycache__/
11+
*.py[cod]
12+
*.so
13+
*.dylib
14+
*.dll
15+
.DS_Store
16+
.idea/
17+
.vscode/
18+
venv/
19+
.venv/

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "data/beadcolors"]
2+
path = data/beadcolors
3+
url = https://github.com/maxcleme/beadcolors.git
4+
[submodule "data/pindou-color-data"]
5+
path = data/pindou-color-data
6+
url = https://github.com/HansBug/pindou-color-data.git

.readthedocs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-24.04
5+
tools:
6+
python: "3.12"
7+
apt_packages:
8+
- make
9+
10+
sphinx:
11+
configuration: docs/source/conf.py
12+
fail_on_warning: false
13+
14+
python:
15+
install:
16+
- requirements: requirements-doc.txt
17+
- method: pip
18+
path: .

AGENTS.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# AGENTS.md
2+
3+
This repository is a pure Python library for converting images into fuse-bead pattern data.
4+
5+
## Scope
6+
7+
- Keep `pypindou` usable as a library. Do not add a CLI unless the project direction changes explicitly.
8+
- Core input is an image; core output is a `Pattern` with grid, legend/counts, preview rendering, and metadata.
9+
- Keep palette data generated from submodules with `make resource`; do not hand-edit `pypindou/resources/palettes.json`.
10+
11+
## Data Sources
12+
13+
- `data/pindou-color-data` is the domestic palette data source maintained at `HansBug/pindou-color-data`.
14+
- `data/beadcolors` is the international palette data source maintained at `maxcleme/beadcolors`.
15+
- After changing submodules or resource-building logic, run `make resource` and commit the generated `pypindou/resources/palettes.json`.
16+
- Colors marked `unidentified: true` are excluded by default. Do not silently drop that flag when transforming data.
17+
18+
## Code Style
19+
20+
- Follow the local module layout: `color`, `image`, `pattern`, `benchmark`.
21+
- Test paths mirror module paths under `test/`.
22+
- Keep public APIs small and importable from `pypindou.__init__` only when they are stable enough for users.
23+
- Prefer explicit dataclasses for public return objects.
24+
25+
## Verification
26+
27+
Before pushing meaningful changes:
28+
29+
```bash
30+
make resource
31+
make test
32+
make docs
33+
make package
34+
```
35+
36+
If a change only touches docs or CI, run the relevant narrower command and mention what was skipped.
37+
38+
## Future Work
39+
40+
Planned directions include:
41+
42+
- better palette reduction metrics and benchmarks;
43+
- board-aware pagination and placement constraints;
44+
- PDF/XLSX export as downstream helpers;
45+
- optional background removal / SAM integration through extras;
46+
- human-friendly color replacement and operation-cost heuristics.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

LICENSE

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
1. Definitions.
8+
9+
"License" shall mean the terms and conditions for use, reproduction, and
10+
distribution as defined by Sections 1 through 9 of this document.
11+
12+
"Licensor" shall mean the copyright owner or entity authorized by the
13+
copyright owner that is granting the License.
14+
15+
"Legal Entity" shall mean the union of the acting entity and all other
16+
entities that control, are controlled by, or are under common control with
17+
that entity. For the purposes of this definition, "control" means (i) the
18+
power, direct or indirect, to cause the direction or management of such
19+
entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20+
(50%) or more of the outstanding shares, or (iii) beneficial ownership of
21+
such entity.
22+
23+
"You" (or "Your") shall mean an individual or Legal Entity exercising
24+
permissions granted by this License.
25+
26+
"Source" form shall mean the preferred form for making modifications,
27+
including but not limited to software source code, documentation source,
28+
and configuration files.
29+
30+
"Object" form shall mean any form resulting from mechanical transformation
31+
or translation of a Source form, including but not limited to compiled
32+
object code, generated documentation, and conversions to other media types.
33+
34+
"Work" shall mean the work of authorship, whether in Source or Object form,
35+
made available under the License, as indicated by a copyright notice that
36+
is included in or attached to the work.
37+
38+
"Derivative Works" shall mean any work, whether in Source or Object form,
39+
that is based on (or derived from) the Work and for which the editorial
40+
revisions, annotations, elaborations, or other modifications represent, as
41+
a whole, an original work of authorship. For the purposes of this License,
42+
Derivative Works shall not include works that remain separable from, or
43+
merely link (or bind by name) to the interfaces of, the Work and Derivative
44+
Works thereof.
45+
46+
"Contribution" shall mean any work of authorship, including the original
47+
version of the Work and any modifications or additions to that Work or
48+
Derivative Works thereof, that is intentionally submitted to Licensor for
49+
inclusion in the Work by the copyright owner or by an individual or Legal
50+
Entity authorized to submit on behalf of the copyright owner.
51+
52+
"Contributor" shall mean Licensor and any individual or Legal Entity on
53+
behalf of whom a Contribution has been received by Licensor and subsequently
54+
incorporated within the Work.
55+
56+
2. Grant of Copyright License. Subject to the terms and conditions of this
57+
License, each Contributor hereby grants to You a perpetual, worldwide,
58+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
59+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
60+
sublicense, and distribute the Work and such Derivative Works in Source or
61+
Object form.
62+
63+
3. Grant of Patent License. Subject to the terms and conditions of this
64+
License, each Contributor hereby grants to You a perpetual, worldwide,
65+
non-exclusive, no-charge, royalty-free, irrevocable patent license to make,
66+
have made, use, offer to sell, sell, import, and otherwise transfer the Work.
67+
68+
4. Redistribution. You may reproduce and distribute copies of the Work or
69+
Derivative Works thereof in any medium, with or without modifications, and
70+
in Source or Object form, provided that You meet the following conditions:
71+
72+
(a) You must give any other recipients of the Work or Derivative Works a
73+
copy of this License; and
74+
75+
(b) You must cause any modified files to carry prominent notices stating
76+
that You changed the files; and
77+
78+
(c) You must retain, in the Source form of any Derivative Works that You
79+
distribute, all copyright, patent, trademark, and attribution notices from
80+
the Source form of the Work, excluding those notices that do not pertain
81+
to any part of the Derivative Works; and
82+
83+
(d) If the Work includes a "NOTICE" text file as part of its distribution,
84+
then any Derivative Works that You distribute must include a readable copy
85+
of the attribution notices contained within such NOTICE file.
86+
87+
5. Submission of Contributions. Unless You explicitly state otherwise, any
88+
Contribution intentionally submitted for inclusion in the Work by You to
89+
the Licensor shall be under the terms and conditions of this License.
90+
91+
6. Trademarks. This License does not grant permission to use the trade names,
92+
trademarks, service marks, or product names of the Licensor, except as
93+
required for reasonable and customary use in describing the origin of the
94+
Work and reproducing the content of the NOTICE file.
95+
96+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to
97+
in writing, Licensor provides the Work on an "AS IS" BASIS, WITHOUT WARRANTIES
98+
OR CONDITIONS OF ANY KIND, either express or implied.
99+
100+
8. Limitation of Liability. In no event and under no legal theory, whether
101+
in tort, contract, or otherwise, unless required by applicable law, shall
102+
any Contributor be liable to You for damages arising in any way out of the
103+
use of or inability to use the Work.
104+
105+
9. Accepting Warranty or Additional Liability. While redistributing the Work
106+
or Derivative Works thereof, You may choose to offer support, warranty,
107+
indemnity, or other liability obligations. However, in accepting such
108+
obligations, You may act only on Your own behalf and on Your sole
109+
responsibility.
110+
111+
END OF TERMS AND CONDITIONS

0 commit comments

Comments
 (0)