提交 03e93b9a 编写于 作者: N Nigel Tao

freetype: update for image/draw changes.

R=r
CC=golang-dev
http://codereview.appspot.com/4620044
上级 fdfcd83e
...@@ -7,11 +7,11 @@ package main ...@@ -7,11 +7,11 @@ package main
import ( import (
"bufio" "bufio"
"exp/draw"
"flag" "flag"
"fmt" "fmt"
"freetype-go.googlecode.com/hg/freetype" "freetype-go.googlecode.com/hg/freetype"
"image" "image"
"image/draw"
"image/png" "image/png"
"io/ioutil" "io/ioutil"
"log" "log"
...@@ -86,7 +86,7 @@ func main() { ...@@ -86,7 +86,7 @@ func main() {
ruler = image.RGBAColor{0x22, 0x22, 0x22, 0xff} ruler = image.RGBAColor{0x22, 0x22, 0x22, 0xff}
} }
rgba := image.NewRGBA(640, 480) rgba := image.NewRGBA(640, 480)
draw.Draw(rgba, rgba.Bounds(), bg, image.ZP) draw.Draw(rgba, rgba.Bounds(), bg, image.ZP, draw.Src)
c := freetype.NewContext() c := freetype.NewContext()
c.SetDPI(*dpi) c.SetDPI(*dpi)
c.SetFont(font) c.SetFont(font)
......
...@@ -7,9 +7,9 @@ package main ...@@ -7,9 +7,9 @@ package main
import ( import (
"bufio" "bufio"
"exp/draw"
"fmt" "fmt"
"image" "image"
"image/draw"
"image/png" "image/png"
"log" "log"
"os" "os"
...@@ -51,8 +51,8 @@ func main() { ...@@ -51,8 +51,8 @@ func main() {
h = 200 h = 200
) )
rgba := image.NewRGBA(w, h) rgba := image.NewRGBA(w, h)
draw.Draw(rgba, image.Rect(0, 0, w, h/2), image.Black, image.ZP) draw.Draw(rgba, image.Rect(0, 0, w, h/2), image.Black, image.ZP, draw.Src)
draw.Draw(rgba, image.Rect(0, h/2, w, h), image.White, image.ZP) draw.Draw(rgba, image.Rect(0, h/2, w, h), image.White, image.ZP, draw.Src)
mask := image.NewAlpha(50, 50) mask := image.NewAlpha(50, 50)
painter := raster.NewAlphaSrcPainter(mask) painter := raster.NewAlphaSrcPainter(mask)
gammas := []float64{1.0 / 10.0, 1.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0, 4.0 / 5.0, 1.0, 5.0 / 4.0, 3.0 / 2.0, 2.0, 3.0, 10.0} gammas := []float64{1.0 / 10.0, 1.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0, 4.0 / 5.0, 1.0, 5.0 / 4.0, 3.0 / 2.0, 2.0, 3.0, 10.0}
......
...@@ -7,9 +7,9 @@ package main ...@@ -7,9 +7,9 @@ package main
import ( import (
"bufio" "bufio"
"exp/draw"
"fmt" "fmt"
"image" "image"
"image/draw"
"image/png" "image/png"
"log" "log"
"os" "os"
...@@ -113,7 +113,7 @@ func showNodes(m *image.RGBA, ns []node) { ...@@ -113,7 +113,7 @@ func showNodes(m *image.RGBA, ns []node) {
for _, n := range ns { for _, n := range ns {
p := p(n) p := p(n)
x, y := int(p.X)/256, int(p.Y)/256 x, y := int(p.X)/256, int(p.Y)/256
if !m.Bounds().Contains(image.Point{x, y}) { if !(image.Point{x, y}).In(m.Bounds()) {
continue continue
} }
var c image.Color var c image.Color
...@@ -147,7 +147,7 @@ func main() { ...@@ -147,7 +147,7 @@ func main() {
// Draw the mask image (in gray) onto an RGBA image. // Draw the mask image (in gray) onto an RGBA image.
rgba := image.NewRGBA(w, h) rgba := image.NewRGBA(w, h)
gray := image.NewColorImage(image.AlphaColor{0x1f}) gray := image.NewColorImage(image.AlphaColor{0x1f})
draw.Draw(rgba, rgba.Bounds(), image.Black, image.ZP) draw.Draw(rgba, rgba.Bounds(), image.Black, image.ZP, draw.Src)
draw.DrawMask(rgba, rgba.Bounds(), gray, image.ZP, mask, image.ZP, draw.Over) draw.DrawMask(rgba, rgba.Bounds(), gray, image.ZP, mask, image.ZP, draw.Over)
showNodes(rgba, outside) showNodes(rgba, outside)
showNodes(rgba, inside) showNodes(rgba, inside)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册