MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / imageOperationToString

Function imageOperationToString

source/core/StarImageProcessing.cpp:262–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262String imageOperationToString(ImageOperation const& operation) {
263 if (auto op = operation.ptr<HueShiftImageOperation>()) {
264 return strf("hueshift={}", op->hueShiftAmount * 360.0f);
265 } else if (auto op = operation.ptr<SaturationShiftImageOperation>()) {
266 return strf("saturation={}", op->saturationShiftAmount * 100.0f);
267 } else if (auto op = operation.ptr<BrightnessMultiplyImageOperation>()) {
268 return strf("brightness={}", (op->brightnessMultiply - 1.0f) * 100.0f);
269 } else if (auto op = operation.ptr<FadeToColorImageOperation>()) {
270 return strf("fade={}={}", Color::rgb(op->color).toHex(), op->amount);
271 } else if (auto op = operation.ptr<ScanLinesImageOperation>()) {
272 return strf("scanlines={}={}={}={}",
273 Color::rgb(op->fade1.color).toHex(),
274 op->fade1.amount,
275 Color::rgb(op->fade2.color).toHex(),
276 op->fade2.amount);
277 } else if (auto op = operation.ptr<SetColorImageOperation>()) {
278 return strf("setcolor={}", Color::rgb(op->color).toHex());
279 } else if (auto op = operation.ptr<ColorReplaceImageOperation>()) {
280 String str = "replace";
281 for (auto const& pair : op->colorReplaceMap)
282 str += strf(";{}={}", Color::rgba(pair.first).toHex(), Color::rgba(pair.second).toHex());
283 return str;
284 } else if (auto op = operation.ptr<AlphaMaskImageOperation>()) {
285 if (op->mode == AlphaMaskImageOperation::Additive)
286 return strf("addmask={};{};{}", op->maskImages.join("+"), op->offset[0], op->offset[1]);
287 else if (op->mode == AlphaMaskImageOperation::Subtractive)
288 return strf("submask={};{};{}", op->maskImages.join("+"), op->offset[0], op->offset[1]);
289 } else if (auto op = operation.ptr<BlendImageOperation>()) {
290 if (op->mode == BlendImageOperation::Multiply)
291 return strf("blendmult={};{};{}", op->blendImages.join("+"), op->offset[0], op->offset[1]);
292 else if (op->mode == BlendImageOperation::Screen)
293 return strf("blendscreen={};{};{}", op->blendImages.join("+"), op->offset[0], op->offset[1]);
294 } else if (auto op = operation.ptr<MultiplyImageOperation>()) {
295 return strf("multiply={}", Color::rgba(op->color).toHex());
296 } else if (auto op = operation.ptr<BorderImageOperation>()) {
297 if (op->outlineOnly)
298 return strf("outline={};{};{}", op->pixels, Color::rgba(op->startColor).toHex(), Color::rgba(op->endColor).toHex());
299 else
300 return strf("border={};{};{}", op->pixels, Color::rgba(op->startColor).toHex(), Color::rgba(op->endColor).toHex());
301 } else if (auto op = operation.ptr<ScaleImageOperation>()) {
302 if (op->mode == ScaleImageOperation::Nearest)
303 return strf("scalenearest={}", op->scale);
304 else if (op->mode == ScaleImageOperation::Bilinear)
305 return strf("scalebilinear={}", op->scale);
306 else if (op->mode == ScaleImageOperation::Bicubic)
307 return strf("scalebicubic={}", op->scale);
308 } else if (auto op = operation.ptr<CropImageOperation>()) {
309 return strf("crop={};{};{};{}", op->subset.xMin(), op->subset.xMax(), op->subset.yMin(), op->subset.yMax());
310 } else if (auto op = operation.ptr<FlipImageOperation>()) {
311 if (op->mode == FlipImageOperation::FlipX)
312 return "flipx";
313 else if (op->mode == FlipImageOperation::FlipY)
314 return "flipy";
315 else if (op->mode == FlipImageOperation::FlipXY)
316 return "flipxy";
317 }
318
319 return "";

Callers 7

MonsterMethod · 0.85
worldHorizonImagesMethod · 0.85
monsterPortraitMethod · 0.85
renderObjectPreviewsMethod · 0.85
beamDrawablesMethod · 0.85
renderImplMethod · 0.85

Calls 7

strfFunction · 0.85
toHexMethod · 0.80
xMinMethod · 0.80
xMaxMethod · 0.80
yMinMethod · 0.80
yMaxMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected