% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/render_gamma_linear.R
\name{render_gamma_linear}
\alias{render_gamma_linear}
\title{Render Gamma/Linear}
\usage{
render_gamma_linear(color, srgb_to_linear = TRUE, as_hex = FALSE)
}
\arguments{
\item{color}{A \code{rayimg}, hex color string (or vector), length-3 numeric RGB vector,
or RGB/RGBA matrix.}

\item{srgb_to_linear}{Default \code{TRUE}. If \code{TRUE}, converts sRGB-encoded data to linear light.
If \code{FALSE}, converts linear-light data to sRGB.}

\item{as_hex}{Default \code{FALSE}. When \code{srgb_to_linear = FALSE} and input is an RGB/RGBA
matrix or array, returns hex: for matrices a length-\code{n} vector; for arrays a
length-\code{prod(dim(x)[1:2])} vector in column-major order. Alpha (if present) is passed through.}
}
\value{
Same shape/type as input unless \code{as_hex = TRUE} on matrix/array with \code{srgb_to_linear = FALSE},
in which case a character vector of hex codes is returned.
}
\description{
Convert sRGB-encoded color data to linear light (and vice versa).
}
\examples{
# Numeric RGB vector (sRGB -> linear -> back to sRGB)
srgb_vec = c(0.2, 0.4, 0.6)
linear_vec = render_gamma_linear(srgb_vec)
render_gamma_linear(linear_vec, srgb_to_linear = FALSE)

# Hex input (single color)
linear_from_hex = render_gamma_linear("#336699")
render_gamma_linear(linear_from_hex, srgb_to_linear = FALSE, as_hex = TRUE)

# Greyscale matrix (treated as image plane)
grey_image = matrix(c(0.1, 0.5, 0.9, 0.3), nrow = 2)
linear_grey = render_gamma_linear(grey_image)
render_gamma_linear(linear_grey, srgb_to_linear = FALSE, as_hex = TRUE)

# Array with a single greyscale channel
grey_pixels = array(c(0.2, 0.7), dim = c(1, 2, 1))
linear_grey_arr = render_gamma_linear(grey_pixels)
render_gamma_linear(linear_grey_arr, srgb_to_linear = FALSE, as_hex = TRUE)

# Array with greyscale + alpha
grey_alpha = array(c(0.3, 0.9, 0.6, 0.4), dim = c(1, 2, 2))
linear_grey_alpha = render_gamma_linear(grey_alpha)
render_gamma_linear(linear_grey_alpha, srgb_to_linear = FALSE, as_hex = TRUE)

# RGB array (3 channels)
rgb_pixels = array(
  c(
    0.2, 0.4, 0.6,
    0.7, 0.1, 0.3
  ),
  dim = c(1, 2, 3)
)
linear_rgb = render_gamma_linear(rgb_pixels)
render_gamma_linear(linear_rgb, srgb_to_linear = FALSE, as_hex = TRUE)

# RGBA array (alpha channel preserved)
rgba_pixels = array(
  c(
    0.2, 0.4, 0.6, 0.5,
    0.7, 0.1, 0.3, 0.8
  ),
  dim = c(1, 2, 4)
)
linear_rgba = render_gamma_linear(rgba_pixels)
render_gamma_linear(linear_rgba, srgb_to_linear = FALSE, as_hex = TRUE)

# rayimg input retains metadata and supports hex conversion
linear_img = render_gamma_linear(ray_read_image(rgba_pixels))
render_gamma_linear(linear_img, srgb_to_linear = FALSE, as_hex = TRUE)
}
