diff --git a/draw/gen.go b/draw/gen.go index cb5e12f..b02368a 100644 --- a/draw/gen.go +++ b/draw/gen.go @@ -366,48 +366,28 @@ func expnDollar(prefix, dollar, suffix string, d *data) string { default: log.Fatalf("bad dType %q", d.dType) case "Image": - switch d.sType { - default: - return argf(args, ""+ - "if dstMask != nil {\n"+ - " qr, qg, qb, qa := dst.At($0, $1).RGBA()\n"+ - " _, _, _, ma := dstMask.At(dmp.X + $0, dmp.Y + $1).RGBA()\n"+ - " pr = pr * ma / 0xffff\n"+ - " pg = pg * ma / 0xffff\n"+ - " pb = pb * ma / 0xffff\n"+ - " pa = pa * ma / 0xffff\n"+ - " $2a1 := 0xffff - ma\n"+ // Note that this is ma, not $2a. - " dstColorRGBA64.R = uint16(qr*$2a1/0xffff + $2r)\n"+ - " dstColorRGBA64.G = uint16(qg*$2a1/0xffff + $2g)\n"+ - " dstColorRGBA64.B = uint16(qb*$2a1/0xffff + $2b)\n"+ - " dstColorRGBA64.A = uint16(qa*$2a1/0xffff + $2a)\n"+ - " dst.Set($0, $1, dstColor)\n"+ - "} else {\n"+ - " dstColorRGBA64.R = uint16($2r)\n"+ - " dstColorRGBA64.G = uint16($2g)\n"+ - " dstColorRGBA64.B = uint16($2b)\n"+ - " dstColorRGBA64.A = uint16($2a)\n"+ - " dst.Set($0, $1, dstColor)\n"+ - "}", - ) - case "*image.Gray": - return argf(args, ""+ - "out := uint16($2r)\n"+ - "dstColorRGBA64.R = out\n"+ - "dstColorRGBA64.G = out\n"+ - "dstColorRGBA64.B = out\n"+ - "dstColorRGBA64.A = 0xffff\n"+ - "dst.Set($0, $1, dstColor)", - ) - case "*image.YCbCr": - return argf(args, ""+ - "dstColorRGBA64.R = uint16($2r)\n"+ - "dstColorRGBA64.G = uint16($2g)\n"+ - "dstColorRGBA64.B = uint16($2b)\n"+ - "dstColorRGBA64.A = 0xffff\n"+ - "dst.Set($0, $1, dstColor)", - ) - } + return argf(args, ""+ + "if dstMask != nil {\n"+ + " qr, qg, qb, qa := dst.At($0, $1).RGBA()\n"+ + " _, _, _, ma := dstMask.At(dmp.X + $0, dmp.Y + $1).RGBA()\n"+ + " pr = pr * ma / 0xffff\n"+ + " pg = pg * ma / 0xffff\n"+ + " pb = pb * ma / 0xffff\n"+ + " pa = pa * ma / 0xffff\n"+ + " $2a1 := 0xffff - ma\n"+ // Note that this is ma, not $2a. + " dstColorRGBA64.R = uint16(qr*$2a1/0xffff + $2r)\n"+ + " dstColorRGBA64.G = uint16(qg*$2a1/0xffff + $2g)\n"+ + " dstColorRGBA64.B = uint16(qb*$2a1/0xffff + $2b)\n"+ + " dstColorRGBA64.A = uint16(qa*$2a1/0xffff + $2a)\n"+ + " dst.Set($0, $1, dstColor)\n"+ + "} else {\n"+ + " dstColorRGBA64.R = uint16($2r)\n"+ + " dstColorRGBA64.G = uint16($2g)\n"+ + " dstColorRGBA64.B = uint16($2b)\n"+ + " dstColorRGBA64.A = uint16($2a)\n"+ + " dst.Set($0, $1, dstColor)\n"+ + "}", + ) case "*image.RGBA": switch d.sType { default: @@ -488,48 +468,28 @@ func expnDollar(prefix, dollar, suffix string, d *data) string { default: log.Fatalf("bad dType %q", d.dType) case "Image": - switch d.sType { - default: - ret = argf(args, ""+ - "if dstMask != nil {\n"+ - " qr, qg, qb, qa := dst.At($0, $1).RGBA()\n"+ - " _, _, _, ma := dstMask.At(dmp.X + $0, dmp.Y + $1).RGBA()\n"+ - " pr := uint32($2($3r * $4)) * ma / 0xffff\n"+ - " pg := uint32($2($3g * $4)) * ma / 0xffff\n"+ - " pb := uint32($2($3b * $4)) * ma / 0xffff\n"+ - " pa := uint32($2($3a * $4)) * ma / 0xffff\n"+ - " pa1 := 0xffff - ma\n"+ // Note that this is ma, not pa. - " dstColorRGBA64.R = uint16(qr*pa1/0xffff + pr)\n"+ - " dstColorRGBA64.G = uint16(qg*pa1/0xffff + pg)\n"+ - " dstColorRGBA64.B = uint16(qb*pa1/0xffff + pb)\n"+ - " dstColorRGBA64.A = uint16(qa*pa1/0xffff + pa)\n"+ - " dst.Set($0, $1, dstColor)\n"+ - "} else {\n"+ - " dstColorRGBA64.R = $2($3r * $4)\n"+ - " dstColorRGBA64.G = $2($3g * $4)\n"+ - " dstColorRGBA64.B = $2($3b * $4)\n"+ - " dstColorRGBA64.A = $2($3a * $4)\n"+ - " dst.Set($0, $1, dstColor)\n"+ - "}", - ) - case "*image.Gray": - ret = argf(args, ""+ - "out := $2($3r * $4)\n"+ - "dstColorRGBA64.R = out\n"+ - "dstColorRGBA64.G = out\n"+ - "dstColorRGBA64.B = out\n"+ - "dstColorRGBA64.A = 0xffff\n"+ - "dst.Set($0, $1, dstColor)", - ) - case "*image.YCbCr": - ret = argf(args, ""+ - "dstColorRGBA64.R = $2($3r * $4)\n"+ - "dstColorRGBA64.G = $2($3g * $4)\n"+ - "dstColorRGBA64.B = $2($3b * $4)\n"+ - "dstColorRGBA64.A = 0xffff\n"+ - "dst.Set($0, $1, dstColor)", - ) - } + ret = argf(args, ""+ + "if dstMask != nil {\n"+ + " qr, qg, qb, qa := dst.At($0, $1).RGBA()\n"+ + " _, _, _, ma := dstMask.At(dmp.X + $0, dmp.Y + $1).RGBA()\n"+ + " pr := uint32($2($3r * $4)) * ma / 0xffff\n"+ + " pg := uint32($2($3g * $4)) * ma / 0xffff\n"+ + " pb := uint32($2($3b * $4)) * ma / 0xffff\n"+ + " pa := uint32($2($3a * $4)) * ma / 0xffff\n"+ + " pa1 := 0xffff - ma\n"+ // Note that this is ma, not pa. + " dstColorRGBA64.R = uint16(qr*pa1/0xffff + pr)\n"+ + " dstColorRGBA64.G = uint16(qg*pa1/0xffff + pg)\n"+ + " dstColorRGBA64.B = uint16(qb*pa1/0xffff + pb)\n"+ + " dstColorRGBA64.A = uint16(qa*pa1/0xffff + pa)\n"+ + " dst.Set($0, $1, dstColor)\n"+ + "} else {\n"+ + " dstColorRGBA64.R = $2($3r * $4)\n"+ + " dstColorRGBA64.G = $2($3g * $4)\n"+ + " dstColorRGBA64.B = $2($3b * $4)\n"+ + " dstColorRGBA64.A = $2($3a * $4)\n"+ + " dst.Set($0, $1, dstColor)\n"+ + "}", + ) case "*image.RGBA": switch d.sType { default: