Skip to content

Commit

Permalink
[WIP] Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kimikage committed Apr 19, 2024
0 parents commit 332b2e6
Show file tree
Hide file tree
Showing 23 changed files with 769 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
83 changes: 83 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CI
on:
push:
branches: main
tags: ['*']
pull_request:
workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
actions: write
contents: read
strategy:
fail-fast: false
matrix:
version:
- '1.6'
- '1'
- 'nightly'
os:
- ubuntu-latest
- windows-latest
- macos-latest
arch:
- x64
include:
- os: ubuntu-latest
version: '1'
arch: x86
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v4
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}

docs:
name: Documentation
runs-on: ubuntu-latest
permissions:
actions: write # needed to allow julia-actions/cache to proactively delete old caches that it has created
contents: write
statuses: write
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: julia-actions/cache@v1
- name: Configure doc environment
shell: julia --project=docs --color=yes {0}
run: |
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-docdeploy@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
- name: Run doctests
shell: julia --project=docs --color=yes {0}
run: |
using Documenter: DocMeta, doctest
using HDRColorTypes
DocMeta.setdocmeta!(HDRColorTypes, :DocTestSetup, :(using HDRColorTypes); recursive=true)
doctest(HDRColorTypes)
19 changes: 19 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CompatHelper
on:
schedule:
- cron: 51 3 * * *
workflow_dispatch:
jobs:
CompatHelper:
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
31 changes: 31 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: "3"
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Files generated by invoking Julia with --code-coverage
*.jl.cov
*.jl.*.cov

# Files generated by invoking Julia with --track-allocation
*.jl.mem

# System-specific files and directories generated by the BinaryProvider and BinDeps packages
# They contain absolute paths specific to the host computer, and so should not be committed
deps/deps.jl
deps/build.log
deps/downloads/
deps/usr/
deps/src/

# Build artifacts for creating documentation generated by the Documenter package
docs/build/
docs/site/

# File generated by Pkg, the package manager, based on a corresponding Project.toml
# It records a fixed state of all packages used by the project. As such, it should not be
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 kimikage

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 23 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name = "HDRColorTypes"
uuid = "87333eb4-81b9-4398-888a-e743b1ba00b1"
version = "0.1.0"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"

[compat]
Aqua = "0.8"
ColorTypes = "0.11"
Colors = "0.12"
ColorVectorSpace = "0.10"
Test = "1"
julia = "1"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Colors", "ColorVectorSpace", "Test"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# HDRColorTypes.jl
[![Docs Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://kimikage.github.io/HDRColorTypes.jl/stable)
[![Docs Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://kimikage.github.io/HDRColorTypes.jl/dev)
[![CI](https://github.com/kimikage/HDRColorTypes.jl/workflows/CI/badge.svg)](https://github.com/kimikage/HDRColorTypes.jl/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/kimikage/HDRColorTypes.jl/graph/badge.svg?token=YwObVAAvcU)](https://codecov.io/gh/kimikage/HDRColorTypes.jl)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

This package is an add-on to [ColorTypes](https://github.com/JuliaGraphics/ColorTypes.jl),
and provides color types for [high dynamic range](https://en.wikipedia.org/wiki/High_dynamic_range)
imaging.
8 changes: 8 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"

[compat]
Documenter = "1"
24 changes: 24 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Documenter, HDRColorTypes
using ColorTypes
using FixedPointNumbers
using Colors

makedocs(
clean=false,
warnonly=true, # FIXME
checkdocs=:exports,
modules=[HDRColorTypes],
format=Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true",
assets = []),
sitename="HDRColorTypes",
pages=[
"Introduction" => "index.md",
"API Reference" => "api.md",
]
)

deploydocs(
repo="github.com/kimikage/HDRColorTypes.jl.git",
devbranch = "main",
push_preview = true
)
24 changes: 24 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# API Reference
```@contents
Pages = ["api.md"]
```

## Types
```@docs
AbstractRGBE
AbstractXYZE
AbstractCCCE
AbstractRGBE32
AbstractXYZE32
AbstractCCCE32
RGBE32
XYZE32
CCCE32
```

## Functions
```@docs
rgbe32
xyze32
ccce32
```
22 changes: 22 additions & 0 deletions docs/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# HDRColorTypes
This package is an add-on to [ColorTypes](https://github.com/JuliaGraphics/ColorTypes.jl),
and provides color types for [high dynamic range](https://en.wikipedia.org/wiki/High_dynamic_range)
imaging.

Note that types such as `RGB{Float16}` are already supported in `ColorTypes`.
Currently this package supports the Radiance formats [`RGBE32`](@ref) and
[`XYZE32`](@ref).

## `RGBE32` and `XYZE32`
`RGBE32` and `XYZE32` are color types based on floating-point numbers with three
color component mantissa parts and one exponent part shared by the three.
The mantissa parts and exponent part are all represented in 8-bit, and the
colors have the total size of 32-bit.

`RGBE32` and `XYZE32` are defined as types with four fields of type `UInt8` as
follows.
```julia
struct RGBE32{T<:AbstractFloat} <: AbstractRGBE32{T}
c1::UInt8
c2::UInt8
c3::UInt8
e::UInt8
end
```
```julia
struct XYZE32{T<:AbstractFloat} <: AbstractXYZE32{T}
c1::UInt8
c2::UInt8
c3::UInt8
e::UInt8
end
```
The fact that they have four fields contrasts with the fact that `ARGB32` and
`RGB24` have one field of type `UInt32`.
Also, the field names are not `r`, `g`, `b` or `x`, `y`, `z`, but `c1`, `c2`,
`c3`.
This is to prevent direct access to the fields by mistaking a color for `RGB`
or `XYZ`, in addition to the viewpoint of generality.

As the definitions above indicate, `RGBE32` and `XYZ32` are parametric types
with "component type" `T`.
This is common with `RGB{T}` and `XYZ{T}` and different from `ARGB32` and
`RGB24`.
If `T` is not explicitly specified in the constructor, `Float32` is applied.
```@repl ex
using HDRColorTypes
using FixedPointNumbers
RGBE32(100, 0, 0) # constructs an `RGBE32{Float32}`
RGB(100.0, 0, 0), RGB(1, 0, 0) # The determination of `T` differs from `RGB`.
RGBE32{Float16}(10, 20, 30) # You can specify `T` explicitly.
XYZE32{Float64}(10, 20, 30)
```
Of course, the type of the component values is `T`, and the values are lazily
converted.
```@repl ex
using ColorTypes
red(RGBE32{Float16}(3.14, 0, 0))
comp2(XYZE32{Float32}(0, 2.71, 0)) # The actual mantissa part is only 8-bit
```

Note that regardless of the component type `T`, the entities of the instances
of `RGBE32` and `XYZE32` are 32-bit.
```@repl ex
sizeof(RGBE32{Float32})
sizeof(RGBE32{Float64})
```
To be compatible with the `RGB` and `XYZ` constructors, it is not allowed to
pass directly the mantissa and exponent parts to the constructor arguments.
You can use the factory functions [`rgbe32`](@ref) and [`xyze32`](@ref), and
their generic version [`ccce32`](@ref).
```@repl ex
rgbe32(0x12, 0x34, 0x56, 0x78)
xyze32(0x12345678)
ccce32(RGBE32{Float64}, 0x12345678)
```
!!! warning
It is not recommended to `reinterpret` an `RGBE32` or `XYZE32` color to
`UInt32` as it is a source of confusion.
```@repl ex
reinterpret(UInt32, rgbe32(0x12345678))
```
Loading

0 comments on commit 332b2e6

Please sign in to comment.