예제 #1
0
func NewDialog(text string) *writer.Dialog {
	return writer.NewDialog(text)
}
예제 #2
0
func NewEffect(inFN string) *Effect {
	input := reader.Read(inFN)
	output := writer.NewScript()

	fontFace := make(map[string]font.Face)

	for _, style := range input.StyleUsed {
		s := NewStyle(style.Name)
		s.Name = style.Name
		s.FontName = style.FontName
		s.FontSize = style.FontSize
		s.Color = style.Color
		s.Alpha = style.Alpha
		s.Bold = style.Bold
		s.Italic = style.Italic
		s.Scale = style.Scale
		s.Angle = style.Angle
		s.Bord = style.Bord
		s.Shadow = style.Shadow
		s.Alignment = style.Alignment
		s.Margin = style.Margin
		output.AddStyle(s)

		ff, err := utils.FontLoad(s.FontName, s.FontSize)
		if err != nil {
			panic(err)
		}
		fontFace[s.Name] = ff
	}

	// Add the original karaoke commented by default in the script
	// This help to jump to the wanted line in the preview in Aegisub,
	// and/or keep a backup of the timed subs
	dok := NewDialog("### Original Karaoke ###")
	dok.Comment = true
	output.AddDialog(dok)
	for _, dlg := range input.Dialog {
		d := writer.NewDialog(dlg.Text)
		d.Layer = dlg.Layer
		d.Start = dlg.StartTime
		d.End = dlg.EndTime
		d.StyleName = dlg.StyleName
		d.Actor = dlg.Actor
		d.Effect = dlg.Effect
		d.Comment = true
		output.AddDialog(d)
	}
	dke := NewDialog("### Karaoke Effect ###")
	dke.Comment = true
	output.AddDialog(dke)

	return &Effect{
		scriptIn:           input,
		scriptOut:          output,
		Resolution:         input.Resolution,
		VideoPath:          input.VideoPath,
		VideoZoom:          input.VideoZoom,
		VideoPosition:      input.VideoPosition,
		VideoAR:            input.VideoAR,
		MetaFilename:       input.MetaFilename,
		MetaTitle:          input.MetaTitle,
		MetaOriginalScript: input.MetaOriginalScript,
		MetaTranslation:    input.MetaTranslation,
		MetaTiming:         input.MetaTiming,
		Audio:              input.Audio,
		fontFace:           fontFace,
	}
}