chromium/third_party/material_color_utilities/src/cpp/cam/hct_solver.cc

/*
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "cpp/cam/hct_solver.h"

#include <math.h>

#include "cpp/cam/viewing_conditions.h"
#include "cpp/utils/utils.h"

namespace material_color_utilities {

constexpr double kScaledDiscountFromLinrgb[3][3] =;

constexpr double kLinrgbFromScaledDiscount[3][3] =;

constexpr double kYFromLinrgb[3] =;

constexpr double kCriticalPlanes[255] =;

/**
 * Sanitizes a small enough angle in radians.
 *
 * @param angle An angle in radians; must not deviate too much from 0.
 * @return A coterminal angle between 0 and 2pi.
 */
double SanitizeRadians(double angle) {}

/**
 * Delinearizes an RGB component, returning a floating-point number.
 *
 * @param rgb_component 0.0 <= rgb_component <= 100.0, represents linear R/G/B
 * channel
 * @return 0.0 <= output <= 255.0, color channel converted to regular RGB space
 */
double TrueDelinearized(double rgb_component) {}

double ChromaticAdaptation(double component) {}

/**
 * Returns the hue of a linear RGB color in CAM16.
 *
 * @param linrgb The linear RGB coordinates of a color.
 * @return The hue of the color in CAM16, in radians.
 */
double HueOf(Vec3 linrgb) {}

bool AreInCyclicOrder(double a, double b, double c) {}

/**
 * Solves the lerp equation.
 *
 * @param source The starting number.
 * @param mid The number in the middle.
 * @param target The ending number.
 * @return A number t such that lerp(source, target, t) = mid.
 */
double Intercept(double source, double mid, double target) {}

Vec3 LerpPoint(Vec3 source, double t, Vec3 target) {}

double GetAxis(Vec3 vector, int axis) {}

/**
 * Intersects a segment with a plane.
 *
 * @param source The coordinates of point A.
 * @param coordinate The R-, G-, or B-coordinate of the plane.
 * @param target The coordinates of point B.
 * @param axis The axis the plane is perpendicular with. (0: R, 1: G, 2: B)
 * @return The intersection point of the segment AB with the plane R=coordinate,
 * G=coordinate, or B=coordinate
 */
Vec3 SetCoordinate(Vec3 source, double coordinate, Vec3 target, int axis) {}

bool IsBounded(double x) {}

/**
 * Returns the nth possible vertex of the polygonal intersection.
 *
 * @param y The Y value of the plane.
 * @param n The zero-based index of the point. 0 <= n <= 11.
 * @return The nth possible vertex of the polygonal intersection of the y plane
 * and the RGB cube, in linear RGB coordinates, if it exists. If this possible
 * vertex lies outside of the cube,
 *     [-1.0, -1.0, -1.0] is returned.
 */
Vec3 NthVertex(double y, int n) {}

/**
 * Finds the segment containing the desired color.
 *
 * @param y The Y value of the color.
 * @param target_hue The hue of the color.
 * @return A list of two sets of linear RGB coordinates, each corresponding to
 * an endpoint of the segment containing the desired color.
 */
void BisectToSegment(double y, double target_hue, Vec3 out[2]) {}

Vec3 Midpoint(Vec3 a, Vec3 b) {}

int CriticalPlaneBelow(double x) {}

int CriticalPlaneAbove(double x) {}

/**
 * Finds a color with the given Y and hue on the boundary of the cube.
 *
 * @param y The Y value of the color.
 * @param target_hue The hue of the color.
 * @return The desired color, in linear RGB coordinates.
 */
Vec3 BisectToLimit(double y, double target_hue) {}

double InverseChromaticAdaptation(double adapted) {}

/**
 * Finds a color with the given hue, chroma, and Y.
 *
 * @param hue_radians The desired hue in radians.
 * @param chroma The desired chroma.
 * @param y The desired Y.
 * @return The desired color as a hexadecimal integer, if found; 0 otherwise.
 */
Argb FindResultByJ(double hue_radians, double chroma, double y) {}

/**
 * Finds an sRGB color with the given hue, chroma, and L*, if possible.
 *
 * @param hue_degrees The desired hue, in degrees.
 * @param chroma The desired chroma.
 * @param lstar The desired L*.
 * @return A hexadecimal representing the sRGB color. The color has sufficiently
 * close hue, chroma, and L* to the desired values, if possible; otherwise, the
 * hue and L* will be sufficiently close, and chroma will be maximized.
 */
Argb SolveToInt(double hue_degrees, double chroma, double lstar) {}

/**
 * Finds an sRGB color with the given hue, chroma, and L*, if possible.
 *
 * @param hue_degrees The desired hue, in degrees.
 * @param chroma The desired chroma.
 * @param lstar The desired L*.
 * @return An CAM16 object representing the sRGB color. The color has
 * sufficiently close hue, chroma, and L* to the desired values, if possible;
 * otherwise, the hue and L* will be sufficiently close, and chroma will be
 * maximized.
 */
Cam SolveToCam(double hue_degrees, double chroma, double lstar) {}
}  // namespace material_color_utilities