Text effect 5 and 6 - Plain text and then Barrel distortion
()
| 187 | |
| 188 | // Text effect 5 and 6 - Plain text and then Barrel distortion |
| 189 | func textEffect5And6() { |
| 190 | imagick.Initialize() |
| 191 | defer imagick.Terminate() |
| 192 | // This one uses d_args |
| 193 | mw := imagick.NewMagickWand() |
| 194 | defer mw.Destroy() |
| 195 | dw := imagick.NewDrawingWand() |
| 196 | defer dw.Destroy() |
| 197 | pw := imagick.NewPixelWand() |
| 198 | defer pw.Destroy() |
| 199 | // Create a 320x100 transparent canvas |
| 200 | pw.SetColor("none") |
| 201 | mw.NewImage(320, 100, pw) |
| 202 | // Set up a 72 point font |
| 203 | dw.SetFont("Verdana-Bold-Italic") |
| 204 | dw.SetFontSize(72) |
| 205 | // Now draw the text |
| 206 | dw.Annotation(25, 65, "Magick") |
| 207 | // Draw the image on to the mw |
| 208 | mw.DrawImage(dw) |
| 209 | mw.WriteImage("text_plain.png") |
| 210 | // Trim the image |
| 211 | mw.TrimImage(0) |
| 212 | // Add the border |
| 213 | pw.SetColor("none") |
| 214 | mw.BorderImage(pw, 10, 10) |
| 215 | //mw.SetImageMatte(true) |
| 216 | //mw.SetImageVirtualPixelMethod(TransparentVirtualPixelMethod) |
| 217 | // d_args[0] = 0.1;d_args[1] = -0.25;d_args[2] = -0.25; [3] += .1 |
| 218 | // The first value should be positive. If it is negative the image is *really* distorted |
| 219 | d_args[0] = 0.0 |
| 220 | d_args[1] = 0.0 |
| 221 | d_args[2] = 0.5 |
| 222 | // d_args[3] should normally be chosen such the sum of all 4 values is 1 |
| 223 | // so that the result is the same size as the original |
| 224 | // You can override the sum with a different value |
| 225 | // If the sum is greater than 1 the resulting image will be smaller than the original |
| 226 | d_args[3] = 1 - (d_args[0] + d_args[1] + d_args[2]) |
| 227 | // Make the result image smaller so that it isn't as likely |
| 228 | // to overflow the edges |
| 229 | // d_args[3] += 0.1 |
| 230 | // 0.0,0.0,0.5,0.5,0.0,0.0,-0.5,1.9 |
| 231 | d_args[3] = 0.5 |
| 232 | d_args[4] = 0.0 |
| 233 | d_args[5] = 0.0 |
| 234 | d_args[6] = -0.5 |
| 235 | d_args[7] = 1.9 |
| 236 | // DON'T FORGET to set the correct number of arguments here |
| 237 | mw.DistortImage(imagick.DISTORTION_BARREL, d_args, true) |
| 238 | //mw.ResetImagePage("") |
| 239 | // Trim the image again |
| 240 | mw.TrimImage(0) |
| 241 | // Add the border |
| 242 | pw.SetColor("none") |
| 243 | mw.BorderImage(pw, 10, 10) |
| 244 | // and write it |
| 245 | mw.WriteImage("text_barrel.png") |
| 246 | } |
no test coverage detected