载入中...
搜索中...
未找到
PrototypeTextures.cpp
浏览该文件的文档.
71 return std::any_of(kPatterns.begin(), kPatterns.end(), [id](const auto& pattern) { return pattern.id == id; });
75 constexpr std::array<std::string_view, 7> kPalettes{{"dark", "light", "purple", "orange", "green", "red",
127void rectangle(Canvas& canvas, int x0, int y0, int x1, int y1, Color color, float alpha, int width) {
134void grid(Canvas& canvas, int cell, int lineWidth, Color color, float minorAlpha, float majorAlpha, int majorEvery,
167 const int lineWidth = std::clamp(params.getInt("lineWidth", std::max(1, canvas.width / 512)), 1, 64);
175 line(canvas, pad, pad + i * lineWidth * 3, pad + cell / (i + 2), pad + i * lineWidth * 3, foreground,
179 grid(canvas, std::max(2, cell / 2), lineWidth, foreground, minorAlpha, majorAlpha * 0.5f, 4, false);
186 checker(canvas, id == "checker-fine" ? std::max(2, cell / 2) : cell * 2, foreground, minorAlpha);
188 grid(canvas, cell * 2, lineWidth, foreground, minorAlpha * 0.55f, majorAlpha * 0.25f, 4, false);
202 rectangle(canvas, canvas.width / 4, canvas.height / 4, canvas.width * 3 / 4, canvas.height, foreground, 0.95f,
204 rectangle(canvas, canvas.width / 4 + cell / 3, canvas.height / 4 + cell / 3, canvas.width * 3 / 4 - cell / 3,
208 rectangle(canvas, canvas.width / 4, canvas.height / 4, canvas.width * 3 / 4, canvas.height * 3 / 4, foreground,
210 rectangle(canvas, canvas.width / 4 + cell / 3, canvas.height / 4 + cell / 3, canvas.width * 3 / 4 - cell / 3,
222 RecipeDescriptor::grid("tex.prototype." + std::string(pattern.id), std::string(pattern.displayName),
228 schema.params.push_back(ParamDescriptor::floating("minorAlpha", "Minor Line Opacity", 0.10f, 0.0f, 1.0f, 0.01f));
229 schema.params.push_back(ParamDescriptor::floating("majorAlpha", "Major Line Opacity", 0.45f, 0.0f, 1.0f, 0.01f));
231 schema.params.push_back(ParamDescriptor::integer("backgroundR", "Custom Background R", 51, 0, 255));
232 schema.params.push_back(ParamDescriptor::integer("backgroundG", "Custom Background G", 51, 0, 255));
233 schema.params.push_back(ParamDescriptor::integer("backgroundB", "Custom Background B", 53, 0, 255));
242std::span<const PrototypeTextureDescriptor> prototypeTextureDescriptors() noexcept { return kPatterns; }
244eve::Result<std::unique_ptr<image::ImageData>> generatePrototypeTexture(std::string_view patternId,
248 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "unknown prototype texture pattern", "patternId"));
260 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "unknown prototype texture palette",
277 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "prototype texture allocation failed", "image"));
289 registry.registerRecipe(descriptorFor(pattern), [id](const Params& params, std::string& error) {
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
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
void registerRecipe(const std::string &id, TextureRecipeFn fn)
Register a recipe without metadata.
Definition TextureRecipe.cpp:17
Definition EvpackPointGraphLoader.h:12
void registerPrototypeTextureRecipes(TextureRecipeRegistry ®istry)
Register all patterns as tex.prototype.* texture recipes.
Definition PrototypeTextures.cpp:286
std::span< const PrototypeTextureDescriptor > prototypeTextureDescriptors() noexcept
Return the stable catalogue of 13 procedural prototype patterns.
Definition PrototypeTextures.cpp:242
eve::Result< std::unique_ptr< image::ImageData > > generatePrototypeTexture(std::string_view patternId, const Params ¶ms)
Generate a parameterized RGBA8 prototype texture without loading an image asset. @ownership On succes...
Definition PrototypeTextures.cpp:244
WidgetDesc grid(int columns, std::vector< WidgetDesc > children, std::string id)
Fixed-column grid; children are placed in source order.
Definition Widget.cpp:687
@ InvalidArgument
@ NotFound
@ Failed
@ Applied
glm::vec4 Color
Render-neutral RGBA color shared by graphics-facing modules.
Definition RenderTypes.h:8
static ParamDescriptor choice(std::string key, std::string label, std::string defaultValue, std::vector< std::string > choices)
Construct a finite-choice string descriptor.
Definition ParamSchema.cpp:65
static ParamDescriptor floating(std::string key, std::string label, float defaultValue, float minimum, float maximum, float step)
Construct a bounded floating-point descriptor.
Definition ParamSchema.cpp:33
static ParamDescriptor integer(std::string key, std::string label, int defaultValue, int minimum, int maximum, int step=1)
Construct a bounded integer descriptor.
Definition ParamSchema.cpp:19
static RecipeDescriptor grid(std::string id, std::string displayName, std::string category, int minimumWidth, int minimumHeight, int maximumWidth=4096, int maximumHeight=4096)
Create a schema with common seed, width and height parameters.
Definition ParamSchema.cpp:73