Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小雨青年
bild
提交
03ded04e
B
bild
项目概览
小雨青年
/
bild
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
bild
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
03ded04e
编写于
8月 04, 2016
作者:
A
Anthony N. Simon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added Divide, Exclusion, ColorBurn, ColorDodge, LinearBurn, LinearLight and Substract
上级
b5832f6c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
175 addition
and
0 deletion
+175
-0
blend.go
blend.go
+175
-0
未找到文件。
blend.go
浏览文件 @
03ded04e
...
...
@@ -177,6 +177,181 @@ func Difference(a image.Image, b image.Image) *image.RGBA {
return
dst
}
// Divide returns an image after Dividing the value of A by B
func
Divide
(
a
image
.
Image
,
b
image
.
Image
)
*
image
.
RGBA
{
dst
:=
blendOperation
(
a
,
b
,
func
(
c0
color
.
RGBA
,
c1
color
.
RGBA
)
color
.
RGBA
{
r0
:=
float64
(
c0
.
R
)
/
255
g0
:=
float64
(
c0
.
G
)
/
255
b0
:=
float64
(
c0
.
B
)
/
255
a0
:=
float64
(
c0
.
A
)
/
255
r1
:=
float64
(
c1
.
R
)
/
255
g1
:=
float64
(
c1
.
G
)
/
255
b1
:=
float64
(
c1
.
B
)
/
255
a1
:=
float64
(
c1
.
A
)
/
255
r2
:=
uint8
(
clampFloat64
((
r0
/
r1
)
*
255
,
0
,
255
))
g2
:=
uint8
(
clampFloat64
((
g0
/
g1
)
*
255
,
0
,
255
))
b2
:=
uint8
(
clampFloat64
((
b0
/
b1
)
*
255
,
0
,
255
))
a2
:=
uint8
(
clampFloat64
((
a0
/
a1
)
*
255
,
0
,
255
))
return
color
.
RGBA
{
r2
,
g2
,
b2
,
a2
}
})
return
dst
}
// ColorBurn returns an image after applying a Color Burn blend mode
func
ColorBurn
(
a
image
.
Image
,
b
image
.
Image
)
*
image
.
RGBA
{
dst
:=
blendOperation
(
a
,
b
,
func
(
c0
color
.
RGBA
,
c1
color
.
RGBA
)
color
.
RGBA
{
r0
:=
float64
(
c0
.
R
)
/
255
g0
:=
float64
(
c0
.
G
)
/
255
b0
:=
float64
(
c0
.
B
)
/
255
a0
:=
float64
(
c0
.
A
)
/
255
r1
:=
float64
(
c1
.
R
)
/
255
g1
:=
float64
(
c1
.
G
)
/
255
b1
:=
float64
(
c1
.
B
)
/
255
a1
:=
float64
(
c1
.
A
)
/
255
r2
:=
uint8
(
clampFloat64
((
1
-
(
1
-
r0
)
/
r1
)
*
255
,
0
,
255
))
g2
:=
uint8
(
clampFloat64
((
1
-
(
1
-
g0
)
/
g1
)
*
255
,
0
,
255
))
b2
:=
uint8
(
clampFloat64
((
1
-
(
1
-
b0
)
/
b1
)
*
255
,
0
,
255
))
a2
:=
uint8
(
clampFloat64
((
1
-
(
1
-
a0
)
/
a1
)
*
255
,
0
,
255
))
return
color
.
RGBA
{
r2
,
g2
,
b2
,
a2
}
})
return
dst
}
// Exclusion returns an image after applying a Exclusion blend mode
func
Exclusion
(
a
image
.
Image
,
b
image
.
Image
)
*
image
.
RGBA
{
dst
:=
blendOperation
(
a
,
b
,
func
(
c0
color
.
RGBA
,
c1
color
.
RGBA
)
color
.
RGBA
{
r0
:=
float64
(
c0
.
R
)
/
255
g0
:=
float64
(
c0
.
G
)
/
255
b0
:=
float64
(
c0
.
B
)
/
255
a0
:=
float64
(
c0
.
A
)
/
255
r1
:=
float64
(
c1
.
R
)
/
255
g1
:=
float64
(
c1
.
G
)
/
255
b1
:=
float64
(
c1
.
B
)
/
255
a1
:=
float64
(
c1
.
A
)
/
255
r2
:=
uint8
(
clampFloat64
((
r0
+
r1
-
2
*
r0
*
r1
)
*
255
,
0
,
255
))
g2
:=
uint8
(
clampFloat64
((
g0
+
g1
-
2
*
g0
*
g1
)
*
255
,
0
,
255
))
b2
:=
uint8
(
clampFloat64
((
b0
+
b1
-
2
*
b0
*
b1
)
*
255
,
0
,
255
))
a2
:=
uint8
(
clampFloat64
((
a0
+
a1
-
2
*
a0
*
a1
)
*
255
,
0
,
255
))
return
color
.
RGBA
{
r2
,
g2
,
b2
,
a2
}
})
return
dst
}
// ColorDodge returns an image after applying a Color Dodge blend mode
func
ColorDodge
(
a
image
.
Image
,
b
image
.
Image
)
*
image
.
RGBA
{
dst
:=
blendOperation
(
a
,
b
,
func
(
c0
color
.
RGBA
,
c1
color
.
RGBA
)
color
.
RGBA
{
r0
:=
float64
(
c0
.
R
)
/
255
g0
:=
float64
(
c0
.
G
)
/
255
b0
:=
float64
(
c0
.
B
)
/
255
a0
:=
float64
(
c0
.
A
)
/
255
r1
:=
float64
(
c1
.
R
)
/
255
g1
:=
float64
(
c1
.
G
)
/
255
b1
:=
float64
(
c1
.
B
)
/
255
a1
:=
float64
(
c1
.
A
)
/
255
r2
:=
uint8
(
clampFloat64
((
r0
/
(
1
-
r1
))
*
255
,
0
,
255
))
g2
:=
uint8
(
clampFloat64
((
g0
/
(
1
-
g1
))
*
255
,
0
,
255
))
b2
:=
uint8
(
clampFloat64
((
b0
/
(
1
-
b1
))
*
255
,
0
,
255
))
a2
:=
uint8
(
clampFloat64
((
a0
/
(
1
-
a1
))
*
255
,
0
,
255
))
return
color
.
RGBA
{
r2
,
g2
,
b2
,
a2
}
})
return
dst
}
// LinearBurn returns an image after applying a Linear Burn blend mode
func
LinearBurn
(
a
image
.
Image
,
b
image
.
Image
)
*
image
.
RGBA
{
dst
:=
blendOperation
(
a
,
b
,
func
(
c0
color
.
RGBA
,
c1
color
.
RGBA
)
color
.
RGBA
{
r0
:=
float64
(
c0
.
R
)
g0
:=
float64
(
c0
.
G
)
b0
:=
float64
(
c0
.
B
)
a0
:=
float64
(
c0
.
A
)
r1
:=
float64
(
c1
.
R
)
g1
:=
float64
(
c1
.
G
)
b1
:=
float64
(
c1
.
B
)
a1
:=
float64
(
c1
.
A
)
r2
:=
uint8
(
clampFloat64
(
r1
+
r0
-
255
,
0
,
255
))
g2
:=
uint8
(
clampFloat64
(
g1
+
g0
-
255
,
0
,
255
))
b2
:=
uint8
(
clampFloat64
(
b1
+
b0
-
255
,
0
,
255
))
a2
:=
uint8
(
clampFloat64
(
a1
+
a0
-
255
,
0
,
255
))
return
color
.
RGBA
{
r2
,
g2
,
b2
,
a2
}
})
return
dst
}
// LinearLight returns an image after applying a Linear Light blend mode
func
LinearLight
(
a
image
.
Image
,
b
image
.
Image
)
*
image
.
RGBA
{
dst
:=
blendOperation
(
a
,
b
,
func
(
c0
color
.
RGBA
,
c1
color
.
RGBA
)
color
.
RGBA
{
r0
:=
float64
(
c0
.
R
)
g0
:=
float64
(
c0
.
G
)
b0
:=
float64
(
c0
.
B
)
a0
:=
float64
(
c0
.
A
)
r1
:=
float64
(
c1
.
R
)
g1
:=
float64
(
c1
.
G
)
b1
:=
float64
(
c1
.
B
)
a1
:=
float64
(
c1
.
A
)
r2
:=
uint8
(
clampFloat64
(
r1
+
2
*
r0
-
255
,
0
,
255
))
g2
:=
uint8
(
clampFloat64
(
g1
+
2
*
g0
-
255
,
0
,
255
))
b2
:=
uint8
(
clampFloat64
(
b1
+
2
*
b0
-
255
,
0
,
255
))
a2
:=
uint8
(
clampFloat64
(
a1
+
2
*
a0
-
255
,
0
,
255
))
return
color
.
RGBA
{
r2
,
g2
,
b2
,
a2
}
})
return
dst
}
// Substract returns an image after substracting the value of B from A
func
Substract
(
a
image
.
Image
,
b
image
.
Image
)
*
image
.
RGBA
{
dst
:=
blendOperation
(
a
,
b
,
func
(
c0
color
.
RGBA
,
c1
color
.
RGBA
)
color
.
RGBA
{
r0
:=
float64
(
c0
.
R
)
g0
:=
float64
(
c0
.
G
)
b0
:=
float64
(
c0
.
B
)
a0
:=
float64
(
c0
.
A
)
r1
:=
float64
(
c1
.
R
)
g1
:=
float64
(
c1
.
G
)
b1
:=
float64
(
c1
.
B
)
a1
:=
float64
(
c1
.
A
)
r2
:=
uint8
(
clampFloat64
(
r0
-
r1
,
0
,
255
))
g2
:=
uint8
(
clampFloat64
(
g0
-
g1
,
0
,
255
))
b2
:=
uint8
(
clampFloat64
(
b0
-
b1
,
0
,
255
))
a2
:=
uint8
(
clampFloat64
(
a0
-
a1
,
0
,
255
))
return
color
.
RGBA
{
r2
,
g2
,
b2
,
a2
}
})
return
dst
}
// Opacity returns an image which blends the two input images by the percentage provided.
// Percent must be of range 0 <= percent <= 1.0
func
Opacity
(
a
image
.
Image
,
b
image
.
Image
,
percent
float64
)
*
image
.
RGBA
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录