-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat!: add `SignedAxis`, `Axis` and `Octant` iterators * feat!: add `Diagonal` iterators * feat!: add `Clip` and the new clipping algorithm * feat: special-case diagonals * feat: support all signed and unsigned integer coordinates * fix: remove overflow and division by zero * feat: gate `Octant<int64>` behind `octant_64`, add compile-time tests * test: check clipping matches naive clipping via `proptest` * ci: set up new CI workflow * docs: update CI badge * chore: ignore `.DS_Store` --------- Signed-off-by: Nurzhan Sakén <[email protected]>
- Loading branch information
Showing
27 changed files
with
4,033 additions
and
2,120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: CI | ||
on: | ||
workflow_dispatch: | ||
merge_group: | ||
pull_request: | ||
paths-ignore: | ||
- "img/**" | ||
- "**.md" | ||
- LICENSE-APACHE | ||
- LICENSE-MIT | ||
- .gitignore | ||
push: | ||
branches: [ main ] | ||
paths-ignore: | ||
- "img/**" | ||
- "**.md" | ||
- LICENSE-APACHE | ||
- LICENSE-MIT | ||
- .gitignore | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: cargo build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: [ stable, beta, nightly ] | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
- name: Install toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
- name: Default features | ||
run: cargo build --all-targets | ||
- name: Nightly features | ||
if: matrix.rust == 'nightly' | ||
run: cargo build --all-targets -F "nightly try_fold is_empty" | ||
|
||
clippy: | ||
name: cargo clippy | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: [ stable, beta, nightly ] | ||
env: | ||
RUSTFLAGS: -Dwarnings | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
components: clippy | ||
- run: cargo clippy --all-targets | ||
- if: matrix.rust == 'nightly' | ||
run: cargo clippy --all-targets --all-features | ||
|
||
fmt: | ||
name: cargo fmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: rustfmt | ||
- run: cargo fmt --all -- --check | ||
|
||
doc: | ||
name: cargo rustdoc | ||
runs-on: ubuntu-latest | ||
env: | ||
RUSTDOCFLAGS: -Dwarnings | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- uses: dtolnay/install@cargo-docs-rs | ||
- run: cargo docs-rs | ||
|
||
test: | ||
name: cargo test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: [ stable, beta, nightly ] | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
- name: Install toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
- name: Default features | ||
run: cargo test --no-fail-fast -- --skip proptest | ||
- name: Nightly features | ||
if: matrix.rust == 'nightly' | ||
run: cargo test --no-fail-fast -F "nightly try_fold is_empty" -- --skip proptest | ||
|
||
proptest: | ||
name: proptest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
- name: Install toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: Default features | ||
run: cargo test --no-fail-fast proptest |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
.idea | ||
/target | ||
/Cargo.lock |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
[package] | ||
name = "clipline" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
authors = ["Nurzhan Sakén <[email protected]>"] | ||
edition = "2021" | ||
description = "Efficient scan conversion (rasterization) of line segments with clipping to a rectangular window." | ||
readme = "README.md" | ||
description = "Efficient rasterization of line segments with pixel-perfect clipping." | ||
keywords = ["line", "clipping", "bresenham", "rasterization", "grid"] | ||
categories = ["graphics", "rendering", "algorithms", "game-development"] | ||
repository = "https://github.com/nxsaken/clipline/" | ||
license = "MIT OR Apache-2.0" | ||
keywords = ["graphics", "clipping", "line", "bresenham", "rasterization"] | ||
categories = ["graphics", "rendering", "algorithms", "game-development", "rendering"] | ||
readme = "README.md" | ||
rust-version = "1.66.0" | ||
edition = "2021" | ||
include = [ | ||
"**/*.rs", | ||
"Cargo.toml", | ||
] | ||
|
||
[features] | ||
default = ["func", "iter"] | ||
iter = [] | ||
func = [] | ||
default = [] | ||
# Enable Octant<i64/u64> for all targets | ||
# and Octant<isize/usize> for 64-bit targets. | ||
octant_64 = [] | ||
|
||
[dev-dependencies] | ||
criterion = { version = "0.5.1"} | ||
bresenham = "0.1.1" | ||
line_drawing = "1.0.0" | ||
# Enable unstable features. | ||
nightly = [] | ||
# Enable optimized `try_fold` implementations. | ||
# Requires the unstable `try_trait_v2` feature. | ||
try_fold = ["nightly"] | ||
# Enable optimized `is_empty` implementations. | ||
# Requires the unstable `exact_size_is_empty` feature. | ||
is_empty = ["nightly"] | ||
|
||
[[bench]] | ||
name = "bresenham_comparison" | ||
harness = false | ||
[dev-dependencies] | ||
static_assertions = "1.1.0" | ||
proptest = "1.5.0" |
Oops, something went wrong.