mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +02:00
WIP
This commit is contained in:
parent
a2eeda8479
commit
ef27485273
@ -31,9 +31,10 @@ func (p *positionFilter) Draw(dst draw.Image, src image.Image, options *gift.Opt
|
||||
draw.Draw(dst, dst.Bounds(), image.White, dst.Bounds().Min, draw.Over)
|
||||
|
||||
srcBounds := src.Bounds()
|
||||
left, top := (p.viewWidth-srcBounds.Dx())/2, (p.viewHeight-srcBounds.Dy())/2
|
||||
if p.align == PositionLeft {
|
||||
left = 0
|
||||
left, top := 0, (p.viewHeight-srcBounds.Dy())/2
|
||||
|
||||
if p.align == PositionCenter {
|
||||
left = (p.viewWidth - srcBounds.Dx()) / 2
|
||||
}
|
||||
|
||||
if p.align == PositionRight {
|
||||
|
@ -20,8 +20,8 @@ func NewGift(options *ImageOptions) *gift.GIFT {
|
||||
}
|
||||
g.Add(
|
||||
filters.Resize(options.ViewWidth, options.ViewHeight, gift.LanczosResampling),
|
||||
filters.Pixel(),
|
||||
filters.Position(options.ViewWidth, options.ViewHeight, filters.PositionCenter),
|
||||
filters.Pixel(),
|
||||
)
|
||||
return g
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
func NewBar(max int, description string, currentJob, totalJob int) *progressbar.ProgressBar {
|
||||
fmtJob := fmt.Sprintf("%%0%dd", len(fmt.Sprint(totalJob)))
|
||||
fmtDesc := fmt.Sprintf("[%s/%s] %%-15s", fmtJob, fmtJob)
|
||||
return progressbar.DefaultBytesSilent(int64(max))
|
||||
return progressbar.NewOptions(max,
|
||||
progressbar.OptionSetWriter(os.Stderr),
|
||||
progressbar.OptionOnCompletion(func() {
|
||||
|
@ -44,9 +44,14 @@ func (e *ePub) getToc(title string, images []*Image) string {
|
||||
if len(ol.ChildElements()) == 1 && e.StripFirstDirectoryFromToc {
|
||||
ol = ol.ChildElements()[0]
|
||||
}
|
||||
if len(ol.ChildElements()) > 0 {
|
||||
nav.AddChild(ol)
|
||||
}
|
||||
|
||||
beginning := etree.NewElement("li")
|
||||
beginningLink := beginning.CreateElement("a")
|
||||
beginningLink.CreateAttr("href", images[0].TextPath())
|
||||
beginningLink.CreateText("Start of the book")
|
||||
ol.InsertChildAt(0, beginning)
|
||||
|
||||
nav.AddChild(ol)
|
||||
|
||||
doc.Indent(2)
|
||||
r, _ := doc.WriteToString()
|
||||
|
Loading…
x
Reference in New Issue
Block a user