Replace silver screws with black ones, invert colors

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-11-06 17:58:27 +00:00
parent 591aad30ec
commit 0f889e77fc
2 changed files with 50 additions and 14 deletions

View file

@ -16,6 +16,7 @@
*/ */
#include <asset.hpp> #include <asset.hpp>
#include <string.hpp>
#include <system.hpp> #include <system.hpp>
#include <plugin/Plugin.hpp> #include <plugin/Plugin.hpp>
@ -49,6 +50,9 @@ std::string user(std::string filename) {
// get system resource, trimming "res/" prefix if we are loaded as a plugin bundle // get system resource, trimming "res/" prefix if we are loaded as a plugin bundle
std::string system(std::string filename) { std::string system(std::string filename) {
if (string::endsWith(filename, "ComponentLibrary/ScrewSilver.svg")) {
filename = filename.substr(0, filename.size()-32) + "ComponentLibrary/ScrewBlack.svg";
}
return system::join(systemDir, bundlePath.empty() ? filename : trim(filename)); return system::join(systemDir, bundlePath.empty() ? filename : trim(filename));
} }

View file

@ -152,16 +152,15 @@ static const struct {
"Fundamental/Scope.svg", "Fundamental/Scope.svg",
{"path33887","path33891","path33893","path33889"} {"path33887","path33891","path33893","path33889"}
}, },
/* These 2 do not have logos on them? // These 2 do not have logos on them
{ {
"Fundamental/SequentialSwitch1.svg", "Fundamental/SequentialSwitch1.svg",
{"_______","_______","_______","_______"} {nullptr,nullptr,nullptr,nullptr}
}, },
{ {
"Fundamental/SequentialSwitch2.svg", "Fundamental/SequentialSwitch2.svg",
{"_______","_______","_______","_______"} {nullptr,nullptr,nullptr,nullptr}
}, },
*/
{ {
"Fundamental/Split.svg", "Fundamental/Split.svg",
{"path29999","path30003","path29997","path30001"} {"path29999","path30003","path29997","path30001"}
@ -174,16 +173,15 @@ static const struct {
"Fundamental/Unity.svg", "Fundamental/Unity.svg",
{"path21219","path21223","path21217","path21221"} {"path21219","path21223","path21217","path21221"}
}, },
/* These 2 do not have logos on them? // These 2 also do not have logos on them
{ {
"Fundamental/VCA-1.svg", "Fundamental/VCA-1.svg",
{"_______","_______","_______","_______"} {nullptr,nullptr,nullptr,nullptr}
}, },
{ {
"Fundamental/VCA.svg", "Fundamental/VCA.svg",
{"_______","_______","_______","_______"} {nullptr,nullptr,nullptr,nullptr}
}, },
*/
{ {
"Fundamental/VCF.svg", "Fundamental/VCF.svg",
{"path25239","path25243","path25245","path25241"} {"path25239","path25243","path25245","path25241"}
@ -208,7 +206,7 @@ static const struct {
static void removeShape(NSVGimage* const handle, const char* const id) static void removeShape(NSVGimage* const handle, const char* const id)
{ {
for (NSVGshape *shape = handle->shapes, *old = nullptr; shape; old = shape, shape = shape->next) for (NSVGshape *shape = handle->shapes, *old = nullptr; shape != nullptr; old = shape, shape = shape->next)
{ {
if (strcmp(shape->id, id) != 0) if (strcmp(shape->id, id) != 0)
continue; continue;
@ -224,6 +222,31 @@ static void removeShape(NSVGimage* const handle, const char* const id)
} }
} }
static void invertPaint(NSVGpaint& paint)
{
if (paint.type != NSVG_PAINT_COLOR)
return;
switch (paint.color)
{
// scope (do nothing)
case 0x40ffffff:
case 0xff2b281e:
break;
// pure black (convert to not quite pure white)
case 0xff000000:
paint.color = 0xffd0d0d0;
break;
// all others (direct invert)
default:
paint.color = (paint.color & 0xff000000)
| (0xff0000 - (paint.color & 0xff0000))
| (0xff00 - (paint.color & 0xff00))
| (0xff - (paint.color & 0xff));
break;
}
}
extern "C" { extern "C" {
NSVGimage* nsvgParseFromFileCardinal(const char* filename, const char* units, float dpi); NSVGimage* nsvgParseFromFileCardinal(const char* filename, const char* units, float dpi);
} }
@ -243,11 +266,20 @@ NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* con
if (std::strncmp(filename + (filenamelen-filterlen), pathToFilterOut, filterlen) == 0) if (std::strncmp(filename + (filenamelen-filterlen), pathToFilterOut, filterlen) == 0)
{ {
puts("Removing CC-ND deadlock from file..."); if (pathsToFilterOut[i].shapes[0] != nullptr)
removeShape(handle, pathsToFilterOut[i].shapes[0]); {
removeShape(handle, pathsToFilterOut[i].shapes[1]); puts("Removing CC-ND deadlock from file...");
removeShape(handle, pathsToFilterOut[i].shapes[2]); removeShape(handle, pathsToFilterOut[i].shapes[0]);
removeShape(handle, pathsToFilterOut[i].shapes[3]); removeShape(handle, pathsToFilterOut[i].shapes[1]);
removeShape(handle, pathsToFilterOut[i].shapes[2]);
removeShape(handle, pathsToFilterOut[i].shapes[3]);
}
for (NSVGshape* shape = handle->shapes; shape != nullptr; shape = shape->next)
{
invertPaint(shape->fill);
invertPaint(shape->stroke);
}
} }
} }