freetype: update for image.Pix changes.
R=r CC=golang-dev http://codereview.appspot.com/4675071
This commit is contained in:
parent
03e93b9a66
commit
43d4d89685
|
@ -21,17 +21,6 @@ func p(x, y int) raster.Point {
|
|||
return raster.Point{raster.Fix32(x * 256), raster.Fix32(y * 256)}
|
||||
}
|
||||
|
||||
func clear(m *image.Alpha) {
|
||||
b := m.Bounds()
|
||||
for y := b.Min.Y; y < b.Max.Y; y++ {
|
||||
base := y * m.Stride
|
||||
p := m.Pix[base+b.Min.X : base+b.Max.X]
|
||||
for i, _ := range p {
|
||||
p[i] = image.AlphaColor{0}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Draw a rounded corner that is one pixel wide.
|
||||
r := raster.NewRasterizer(50, 50)
|
||||
|
@ -57,7 +46,7 @@ func main() {
|
|||
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}
|
||||
for i, g := range gammas {
|
||||
clear(mask)
|
||||
draw.Draw(mask, mask.Bounds(), image.Transparent, image.ZP, draw.Src)
|
||||
r.Rasterize(raster.NewGammaCorrectionPainter(painter, g))
|
||||
x, y := 50*i+25, 25
|
||||
draw.DrawMask(rgba, image.Rect(x, y, x+50, y+50), image.White, image.ZP, mask, image.ZP, draw.Over)
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"bufio"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/draw"
|
||||
"image/png"
|
||||
"log"
|
||||
"math"
|
||||
|
@ -31,12 +32,7 @@ func main() {
|
|||
t := raster.Fix32(r * math.Tan(math.Pi/8))
|
||||
|
||||
m := image.NewRGBA(800, 600)
|
||||
for y := 0; y < 600; y++ {
|
||||
p := m.Pix[y*m.Stride : y*m.Stride+800]
|
||||
for i := range p {
|
||||
p[i] = image.RGBAColor{63, 63, 63, 255}
|
||||
}
|
||||
}
|
||||
draw.Draw(m, m.Bounds(), &image.ColorImage{image.RGBAColor{63, 63, 63, 255}}, image.ZP, draw.Src)
|
||||
mp := raster.NewRGBAPainter(m)
|
||||
mp.SetColor(image.Black)
|
||||
z := raster.NewRasterizer(800, 600)
|
||||
|
|
|
@ -58,7 +58,7 @@ func (r AlphaOverPainter) Paint(ss []Span, done bool) {
|
|||
if s.X0 >= s.X1 {
|
||||
continue
|
||||
}
|
||||
base := s.Y * r.Image.Stride
|
||||
base := (s.Y-r.Image.Rect.Min.Y)*r.Image.Stride - r.Image.Rect.Min.X
|
||||
p := r.Image.Pix[base+s.X0 : base+s.X1]
|
||||
a := int(s.A >> 24)
|
||||
for i, c := range p {
|
||||
|
@ -99,7 +99,7 @@ func (r AlphaSrcPainter) Paint(ss []Span, done bool) {
|
|||
if s.X0 >= s.X1 {
|
||||
continue
|
||||
}
|
||||
base := s.Y * r.Image.Stride
|
||||
base := (s.Y-r.Image.Rect.Min.Y)*r.Image.Stride - r.Image.Rect.Min.X
|
||||
p := r.Image.Pix[base+s.X0 : base+s.X1]
|
||||
color := image.AlphaColor{uint8(s.A >> 24)}
|
||||
for i := range p {
|
||||
|
@ -141,7 +141,7 @@ func (r *RGBAPainter) Paint(ss []Span, done bool) {
|
|||
if s.X0 >= s.X1 {
|
||||
continue
|
||||
}
|
||||
base := s.Y * r.Image.Stride
|
||||
base := (s.Y-r.Image.Rect.Min.Y)*r.Image.Stride - r.Image.Rect.Min.X
|
||||
p := r.Image.Pix[base+s.X0 : base+s.X1]
|
||||
for i, rgba := range p {
|
||||
// This code is duplicated from drawGlyphOver in $GOROOT/src/pkg/exp/draw/draw.go.
|
||||
|
|
Loading…
Reference in New Issue
Block a user