why did I think that using remove_if was a good idea

This commit is contained in:
Essem 2022-01-15 00:04:34 -06:00
parent e1cfbff5a8
commit 535e6e0e4a
No known key found for this signature in database
GPG Key ID: 7D497397CC3A2A8C
4 changed files with 12 additions and 14 deletions

View File

@ -61,4 +61,4 @@ Napi::Value Blur(const Napi::CallbackInfo &info) {
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}
}

View File

@ -25,8 +25,8 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
Napi::Object result = Napi::Object::New(env);
char *fileData = data.Data();
char *match = "\x21\xFF\x0BNETSCAPE2.0\x03\x01";
char *descriptor = "\x2C\x00\x00\x00\x00";
char *match = (char *)"\x21\xFF\x0BNETSCAPE2.0\x03\x01";
char *descriptor = (char *)"\x2C\x00\x00\x00\x00";
char *lastPos;
bool none = true;
@ -104,4 +104,4 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}
}

View File

@ -32,7 +32,7 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
char *fileData = data.Data();
char *match = "\x00\x21\xF9\x04";
char *match = (char *)"\x00\x21\xF9\x04";
// if passed a delay, use that. otherwise iterate over every frame.
if (delay == 0) {
@ -98,9 +98,8 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
}
for (int i = 0; i < speed - 1; ++i) {
frames.remove_if([counter = 0](const auto x) mutable {
return ++counter % 2 == 0;
});
auto it = frames.begin();
while(it != frames.end() && ++it != frames.end()) it = frames.erase(it);
}
for_each(frames.begin(), frames.end(), magickImage(type));
@ -142,9 +141,8 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
}
for (int i = 0; i < speed - 1; ++i) {
frames.remove_if([counter = 0](const auto x) mutable {
return ++counter % 2 == 0;
});
auto it = frames.begin();
while(it != frames.end() && ++it != frames.end()) it = frames.erase(it);
}
for_each(frames.begin(), frames.end(), magickImage(type));
@ -176,4 +174,4 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}
}

View File

@ -43,7 +43,7 @@ Napi::Value Spin(const Napi::CallbackInfo &info) {
image.virtualPixelMethod(Magick::TransparentVirtualPixelMethod);
image.scale(Geometry("256x256"));
image.alphaChannel(Magick::SetAlphaChannel);
double rotation[1] = {360 * i / coalesced.size()};
double rotation[1] = {(double)360 * i / coalesced.size()};
image.distort(Magick::ScaleRotateTranslateDistortion, 1, rotation);
image.magick("GIF");
mid.push_back(image);
@ -77,4 +77,4 @@ Napi::Value Spin(const Napi::CallbackInfo &info) {
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}
}