https://github.com/jakeroggenbuck/colorgradient-julia
A tool in Julia to make color gradients
https://github.com/jakeroggenbuck/colorgradient-julia
julia julia-language julialang math
Last synced: 8 months ago
JSON representation
A tool in Julia to make color gradients
- Host: GitHub
- URL: https://github.com/jakeroggenbuck/colorgradient-julia
- Owner: JakeRoggenbuck
- License: mit
- Created: 2021-07-14T22:21:13.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-01-01T07:31:42.000Z (over 3 years ago)
- Last Synced: 2025-01-07T16:24:28.109Z (over 1 year ago)
- Topics: julia, julia-language, julialang, math
- Language: Julia
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# colorgradient-julia
- Python version [colorgradient](https://github.com/JakeRoggenbuck/colorgradient)
- Rust version [colorgradient-rs](https://github.com/JakeRoggenbuck/colorgradient-rs)
- Julia version [colorgradient-julia](https://github.com/JakeRoggenbuck/colorgradient-julia)
- C version [colorgradient-c](https://github.com/JakeRoggenbuck/colorgradient-c)
- Go version [colorgradient-go](https://github.com/JakeRoggenbuck/colorgradient-go)
- Clojure version [colorgradient-clj](https://github.com/JakeRoggenbuck/colorgradient-clj)

```jl
# Find the slope of two point
find_slope(x1, y1, x2, y2) = (y2 - y1) / (x2 - x1)
# Find the closest whole numbers on both sides of a x
neighbors(x) = round(x), ceil(x)
# Find the predicted value of y given a value x
function find_y(x, known_x)
# Check if the given value is exactly one in the known list
if round(x) == x
return known_x[x]
end
left_x, right_x = neighbors(x)
left_y = known_x[left_x]
right_y = known_x[right_x]
slope = find_slope(left_x, left_y, right_x, right_y)
return left_y + (slope * (x - left_x))
end
```