more on imgtext func

This commit is contained in:
lordwelch 2016-05-02 10:22:40 -07:00
parent fa6213472f
commit 3c608d3d46
2 changed files with 8 additions and 10 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -2,12 +2,13 @@
package main package main
import ( import (
"strings"
"bytes" "bytes"
"image" "image"
"image/color"
"log" "log"
"math" "math"
"os/exec" "os/exec"
"strings"
"gopkg.in/gographics/imagick.v2/imagick" "gopkg.in/gographics/imagick.v2/imagick"
) )
@ -90,7 +91,7 @@ func (cl *cell) getImage(width, height int) (img *image.RGBA) {
} }
// adding text to image copied from example // adding text to image copied from example
func (cl *cell) imgtext() { func (cl *cell) imgtext(x, y int) {
mw := imagick.NewMagickWand() mw := imagick.NewMagickWand()
defer mw.Destroy() defer mw.Destroy()
dw := imagick.NewDrawingWand() dw := imagick.NewDrawingWand()
@ -103,13 +104,13 @@ func (cl *cell) imgtext() {
mw.NewImage(0, 0, pw) mw.NewImage(0, 0, pw)
// Set up a 72 point white font // Set up a 72 point white font
pw.SetColor("white") pw.SetColor(font.textColor)
dw.SetFillColor(pw) dw.SetFillColor(pw)
dw.SetFont("Verdana-Bold-Italic") dw.SetFont(font.name)
dw.SetFontSize(72) dw.SetFontSize(font.size)
// Add a black outline to the text // Add a black outline to the text
pw.SetColor("black") pw.SetColor(font.OutlineColor)
dw.SetStrokeColor(pw) dw.SetStrokeColor(pw)
// Turn antialias on - not sure this makes a difference // Turn antialias on - not sure this makes a difference
@ -131,7 +132,7 @@ func (cl *cell) imgtext() {
cw := mw.Clone() cw := mw.Clone()
// Set the background colour to blue for the shadow // Set the background colour to blue for the shadow
pw.SetColor("blue") pw.SetColor("black")
mw.SetImageBackgroundColor(pw) mw.SetImageBackgroundColor(pw)
// Opacity is a real number indicating (apparently) percentage // Opacity is a real number indicating (apparently) percentage
@ -140,9 +141,6 @@ func (cl *cell) imgtext() {
// Composite the text on top of the shadow // Composite the text on top of the shadow
mw.CompositeImage(cw, imagick.COMPOSITE_OP_OVER, 5, 5) mw.CompositeImage(cw, imagick.COMPOSITE_OP_OVER, 5, 5)
cw.Destroy() cw.Destroy()
// and write the result
mw.WriteImage("text_shadow.png")
} }
func findfonts() { func findfonts() {