-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add drawable-interline-spacing (#104)
- Loading branch information
1 parent
ff80cef
commit d9c5541
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
import { IDrawable } from "./drawable"; | ||
import { IDrawingWand } from "./drawing-wand"; | ||
|
||
export class DrawableInterlineSpacing implements IDrawable { | ||
private readonly _interlineSpacing: number; | ||
|
||
constructor(interlineSpacing: number) { | ||
this._interlineSpacing = interlineSpacing; | ||
} | ||
|
||
draw(wand: IDrawingWand): void { | ||
wand.interlineSpacing(this._interlineSpacing); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
import { DrawableText } from "../../src/drawables/drawable-text"; | ||
import { DrawableInterlineSpacing } from "../../src/drawables/drawable-interline-spacing"; | ||
import { DrawableFillColor } from "../../src/drawables/drawable-fill-color"; | ||
import { DrawableFont } from "../../src/drawables/drawable-font"; | ||
import { DrawableFontPointSize } from "../../src/drawables/drawable-font-point-size"; | ||
import { MagickColor } from "../../src/magick-color"; | ||
import { TestFonts } from "../test-fonts"; | ||
import { TestImages } from "../test-images"; | ||
|
||
describe("DrawableInterlineSpacing", () => { | ||
it("should write text with increased interline spacing", () => { | ||
TestImages.emptyCanvas.use((image) => { | ||
image.draw([ | ||
new DrawableFont(TestFonts.kaushanScriptRegularTtf.name), | ||
new DrawableFontPointSize(50), | ||
new DrawableInterlineSpacing(10), | ||
new DrawableFillColor(new MagickColor("pink")), | ||
new DrawableText(50, 50, "I\nI"), | ||
]); | ||
|
||
expect(image).toHavePixelWithColor(60, 131, "#ffc0cbff"); | ||
}); | ||
}); | ||
|
||
it("should write text with default interline spacing", () => { | ||
TestImages.emptyCanvas.use((image) => { | ||
image.draw([ | ||
new DrawableFont(TestFonts.kaushanScriptRegularTtf.name), | ||
new DrawableFontPointSize(50), | ||
new DrawableFillColor(new MagickColor("pink")), | ||
new DrawableText(50, 50, "I\nI"), | ||
]); | ||
|
||
expect(image).toHavePixelWithColor(60, 131, "#ffffffff"); | ||
}); | ||
}); | ||
}); |