Add flag to flip speech bubble
This commit is contained in:
parent
b298656515
commit
bb966df085
2 changed files with 12 additions and 1 deletions
|
@ -7,7 +7,8 @@ class SpeechBubbleCommand extends ImageCommand {
|
||||||
gravity: "north",
|
gravity: "north",
|
||||||
resize: true,
|
resize: true,
|
||||||
yscale: 0.2,
|
yscale: 0.2,
|
||||||
alpha: this.specialArgs.alpha
|
alpha: this.specialArgs.alpha,
|
||||||
|
flip: this.specialArgs.flip
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +18,10 @@ class SpeechBubbleCommand extends ImageCommand {
|
||||||
name: "alpha",
|
name: "alpha",
|
||||||
description: "Make the top of the speech bubble transparent",
|
description: "Make the top of the speech bubble transparent",
|
||||||
type: 5
|
type: 5
|
||||||
|
}, {
|
||||||
|
name: "flip",
|
||||||
|
description: "Flips the speech bubble",
|
||||||
|
type: 5
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
||||||
: false;
|
: false;
|
||||||
bool alpha =
|
bool alpha =
|
||||||
obj.Has("alpha") ? obj.Get("alpha").As<Napi::Boolean>().Value() : false;
|
obj.Has("alpha") ? obj.Get("alpha").As<Napi::Boolean>().Value() : false;
|
||||||
|
bool flip =
|
||||||
|
obj.Has("flip") ? obj.Get("flip").As<Napi::Boolean>().Value() : false;
|
||||||
bool mc = obj.Has("mc") ? obj.Get("mc").As<Napi::Boolean>().Value() : false;
|
bool mc = obj.Has("mc") ? obj.Get("mc").As<Napi::Boolean>().Value() : false;
|
||||||
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
@ -43,6 +45,10 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
int nPages = vips_image_get_n_pages(in.get_image());
|
int nPages = vips_image_get_n_pages(in.get_image());
|
||||||
|
|
||||||
|
if (flip) {
|
||||||
|
watermark = watermark.flip(VIPS_DIRECTION_HORIZONTAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (resize && append) {
|
if (resize && append) {
|
||||||
watermark = watermark.resize((double)width / (double)watermark.width());
|
watermark = watermark.resize((double)width / (double)watermark.width());
|
||||||
} else if (resize && yscale) {
|
} else if (resize && yscale) {
|
||||||
|
|
Loading…
Reference in a new issue