载入中...
搜索中...
未找到
PcgColorPreviewSync.cpp
浏览该文件的文档.
3#include <simplesquirrel/simplesquirrel.hpp>
4#include <cmath>
5namespace eve::ui {
6Result<void> PcgColorPreviewSync::sync(float r, float g, float b, float a) {
7 if (!std::isfinite(r) || !std::isfinite(g) || !std::isfinite(b) || !std::isfinite(a))
9 "source color must be finite", "ui.pcgColorPreview.sync"));
10 if (r == 0.f && g == 0.f && b == 0.f) {
11 red_ = green_ = blue_ = 0.5f; alpha_ = 1.f;
12 } else {
13 red_ = r * 2.5f; green_ = g * 2.5f; blue_ = b * 2.5f; alpha_ = a * 2.5f;
14 }
15 return Result<void>::success();
16}
17void exposePcgColorPreviewSyncBindings(ssq::Table& table) {
18 auto cls = table.addClass("PcgColorPreviewSync", ssq::Class::Ctor<PcgColorPreviewSync()>());
19 auto vm = table.getHandle();
20 cls.addFunc("sync", [vm](PcgColorPreviewSync* self, float r, float g, float b, float a) {
21 return eve::script::projectResult(vm, self->sync(r, g, b, a));
22 });
23 cls.addFunc("getRed", [](const PcgColorPreviewSync* self) { return self->getRed(); });
24 cls.addFunc("getGreen", [](const PcgColorPreviewSync* self) { return self->getGreen(); });
25 cls.addFunc("getBlue", [](const PcgColorPreviewSync* self) { return self->getBlue(); });
26 cls.addFunc("getAlpha", [](const PcgColorPreviewSync* self) { return self->getAlpha(); });
27}
28}
HSQUIRRELVM vm
Definition ECS.cpp:20
HSQOBJECT cls
Definition ECS.cpp:21
tensor::Graph g
Definition GpuGraph.cpp:7
double r
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Caller-owned highlighted-color snapshot ported from Pcg ColorPreviewSync.
float getBlue() const noexcept
Return highlighted blue.
float getRed() const noexcept
Return highlighted red.
float getAlpha() const noexcept
Return highlighted alpha.
float getGreen() const noexcept
Return highlighted green.
Result< void > sync(float red, float green, float blue, float alpha)
Synchronize from the source image color exactly as Pcg does on enable.
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
void exposePcgColorPreviewSyncBindings(ssq::Table &table)
Register Pcg color-preview bindings.