예제 #1
0
파일: main.go 프로젝트: rafikk/imagick
// Set up the drawingwand "dw" for the given font name, font size, and colour.
// If the font or size changes sx get the new width of a space
// (the magickwand is required if it is necessary to query the font metrics)
func draw_setfont(mw *imagick.MagickWand, dw *imagick.DrawingWand, font string, size float64, colour string, sx *float64) {
	sflag := false

	if len(font) > 0 {
		dw.SetFont(font)
		sflag = true
	}

	if len(colour) > 0 {
		pw := imagick.NewPixelWand()
		pw.SetColor(colour)
		dw.SetFillColor(pw)
		pw.Destroy()
		sflag = true
	}

	if size > 0 {
		dw.SetFontSize(size)
	}

	// If either the font or the fontsize (or both) have changed
	// we need to get the size of a space again
	if sflag {
		fm := mw.QueryFontMetrics(dw, " ")
		*sx = fm.TextWidth
	}
}
예제 #2
0
파일: main.go 프로젝트: rafikk/imagick
// Given a pattern name (which MUST have a leading #) and a pattern file,
// set up a pattern URL for later reference in the specified drawing wand
// Currently only used in Text Effect 2
func setTilePattern(dw *imagick.DrawingWand, pattern_name, pattern_file string) {
	tw := imagick.NewMagickWand()
	defer tw.Destroy()

	tw.ReadImage(pattern_file)
	// Read the tile's width and height
	w := tw.GetImageWidth()
	h := tw.GetImageHeight()

	dw.PushPattern(pattern_name[1:], 0, 0, float64(w), float64(h))
	dw.Composite(imagick.COMPOSITE_OP_SRC_OVER, 0, 0, 0, 0, tw)
	dw.PopPattern()
	dw.SetFillPatternURL(pattern_name)
}