Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小雨青年
freetype
提交
7b867fea
F
freetype
项目概览
小雨青年
/
freetype
通知
14
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
freetype
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7b867fea
编写于
10月 06, 2011
作者:
N
Nigel Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
freetype: image/color gofix.
R=r, rsc CC=golang-dev
http://codereview.appspot.com/5166052
上级
41885588
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
10 deletion
+14
-10
example/freetype/main.go
example/freetype/main.go
+3
-2
example/raster/main.go
example/raster/main.go
+6
-5
example/round/main.go
example/round/main.go
+3
-2
freetype/raster/paint.go
freetype/raster/paint.go
+2
-1
未找到文件。
example/freetype/main.go
浏览文件 @
7b867fea
...
...
@@ -11,6 +11,7 @@ import (
"fmt"
"freetype-go.googlecode.com/hg/freetype"
"image"
"image/color"
"image/draw"
"image/png"
"io/ioutil"
...
...
@@ -80,10 +81,10 @@ func main() {
// Initialize the context.
fg
,
bg
:=
image
.
Black
,
image
.
White
ruler
:=
image
.
RGBAColor
{
0xdd
,
0xdd
,
0xdd
,
0xff
}
ruler
:=
color
.
RGBA
{
0xdd
,
0xdd
,
0xdd
,
0xff
}
if
*
wonb
{
fg
,
bg
=
image
.
White
,
image
.
Black
ruler
=
image
.
RGBAColor
{
0x22
,
0x22
,
0x22
,
0xff
}
ruler
=
color
.
RGBA
{
0x22
,
0x22
,
0x22
,
0xff
}
}
rgba
:=
image
.
NewRGBA
(
image
.
Rect
(
0
,
0
,
640
,
480
))
draw
.
Draw
(
rgba
,
rgba
.
Bounds
(),
bg
,
image
.
ZP
,
draw
.
Src
)
...
...
example/raster/main.go
浏览文件 @
7b867fea
...
...
@@ -9,6 +9,7 @@ import (
"bufio"
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"log"
...
...
@@ -116,14 +117,14 @@ func showNodes(m *image.RGBA, ns []node) {
if
!
(
image
.
Point
{
x
,
y
})
.
In
(
m
.
Bounds
())
{
continue
}
var
c
image
.
Color
var
c
color
.
Color
switch
n
.
degree
{
case
0
:
c
=
image
.
RGBAColor
{
0
,
255
,
255
,
255
}
c
=
color
.
RGBA
{
0
,
255
,
255
,
255
}
case
1
:
c
=
image
.
RGBAColor
{
255
,
0
,
0
,
255
}
c
=
color
.
RGBA
{
255
,
0
,
0
,
255
}
case
2
:
c
=
image
.
RGBAColor
{
255
,
0
,
0
,
255
}
c
=
color
.
RGBA
{
255
,
0
,
0
,
255
}
}
if
c
!=
nil
{
m
.
Set
(
x
,
y
,
c
)
...
...
@@ -146,7 +147,7 @@ func main() {
// Draw the mask image (in gray) onto an RGBA image.
rgba
:=
image
.
NewRGBA
(
image
.
Rect
(
0
,
0
,
w
,
h
))
gray
:=
image
.
New
ColorImage
(
image
.
AlphaColor
{
0x1f
})
gray
:=
image
.
New
Uniform
(
color
.
Alpha
{
0x1f
})
draw
.
Draw
(
rgba
,
rgba
.
Bounds
(),
image
.
Black
,
image
.
ZP
,
draw
.
Src
)
draw
.
DrawMask
(
rgba
,
rgba
.
Bounds
(),
gray
,
image
.
ZP
,
mask
,
image
.
ZP
,
draw
.
Over
)
showNodes
(
rgba
,
outside
)
...
...
example/round/main.go
浏览文件 @
7b867fea
...
...
@@ -14,6 +14,7 @@ import (
"bufio"
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"log"
...
...
@@ -32,7 +33,7 @@ func main() {
t
:=
raster
.
Fix32
(
r
*
math
.
Tan
(
math
.
Pi
/
8
))
m
:=
image
.
NewRGBA
(
image
.
Rect
(
0
,
0
,
800
,
600
))
draw
.
Draw
(
m
,
m
.
Bounds
(),
&
image
.
ColorImage
{
image
.
RGBAColor
{
63
,
63
,
63
,
255
}},
image
.
ZP
,
draw
.
Src
)
draw
.
Draw
(
m
,
m
.
Bounds
(),
&
image
.
Uniform
{
color
.
RGBA
{
63
,
63
,
63
,
255
}},
image
.
ZP
,
draw
.
Src
)
mp
:=
raster
.
NewRGBAPainter
(
m
)
mp
.
SetColor
(
image
.
Black
)
z
:=
raster
.
NewRasterizer
(
800
,
600
)
...
...
@@ -69,7 +70,7 @@ func main() {
theta
:=
math
.
Pi
*
float64
(
j
)
/
(
n
-
1
)
dx
:=
raster
.
Fix32
(
r
*
math
.
Cos
(
theta
))
dy
:=
raster
.
Fix32
(
r
*
math
.
Sin
(
theta
))
m
.
Set
(
int
((
cx
+
dx
)
/
256
),
int
((
cy
+
dy
)
/
256
),
image
.
RGBAColor
{
255
,
255
,
0
,
255
})
m
.
Set
(
int
((
cx
+
dx
)
/
256
),
int
((
cy
+
dy
)
/
256
),
color
.
RGBA
{
255
,
255
,
0
,
255
})
}
}
...
...
freetype/raster/paint.go
浏览文件 @
7b867fea
...
...
@@ -7,6 +7,7 @@ package raster
import
(
"image"
"image/color"
"image/draw"
"math"
)
...
...
@@ -169,7 +170,7 @@ func (r *RGBAPainter) Paint(ss []Span, done bool) {
}
// SetColor sets the color to paint the spans.
func
(
r
*
RGBAPainter
)
SetColor
(
c
image
.
Color
)
{
func
(
r
*
RGBAPainter
)
SetColor
(
c
color
.
Color
)
{
r
.
cr
,
r
.
cg
,
r
.
cb
,
r
.
ca
=
c
.
RGBA
()
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录