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

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

View file

@ -32,7 +32,7 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
char *fileData = data.Data(); 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 passed a delay, use that. otherwise iterate over every frame.
if (delay == 0) { if (delay == 0) {
@ -98,9 +98,8 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
} }
for (int i = 0; i < speed - 1; ++i) { for (int i = 0; i < speed - 1; ++i) {
frames.remove_if([counter = 0](const auto x) mutable { auto it = frames.begin();
return ++counter % 2 == 0; while(it != frames.end() && ++it != frames.end()) it = frames.erase(it);
});
} }
for_each(frames.begin(), frames.end(), magickImage(type)); 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) { for (int i = 0; i < speed - 1; ++i) {
frames.remove_if([counter = 0](const auto x) mutable { auto it = frames.begin();
return ++counter % 2 == 0; while(it != frames.end() && ++it != frames.end()) it = frames.erase(it);
});
} }
for_each(frames.begin(), frames.end(), magickImage(type)); for_each(frames.begin(), frames.end(), magickImage(type));

View file

@ -43,7 +43,7 @@ Napi::Value Spin(const Napi::CallbackInfo &info) {
image.virtualPixelMethod(Magick::TransparentVirtualPixelMethod); image.virtualPixelMethod(Magick::TransparentVirtualPixelMethod);
image.scale(Geometry("256x256")); image.scale(Geometry("256x256"));
image.alphaChannel(Magick::SetAlphaChannel); 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.distort(Magick::ScaleRotateTranslateDistortion, 1, rotation);
image.magick("GIF"); image.magick("GIF");
mid.push_back(image); mid.push_back(image);