|
|
|
@ -73,11 +73,14 @@ func filterImage(path, fname string) {
|
|
|
|
|
variables["WID"] = imSize.X
|
|
|
|
|
variables["HIG"] = imSize.Y
|
|
|
|
|
variables["REG"] = 0
|
|
|
|
|
fil.location.maxX = imSize.X
|
|
|
|
|
fil.location.maxY = imSize.Y
|
|
|
|
|
|
|
|
|
|
fil = filterState{
|
|
|
|
|
filter{255, 255, 255},
|
|
|
|
|
filter{255,255,255},
|
|
|
|
|
filter{255,255,255},
|
|
|
|
|
filter{255,255,255},
|
|
|
|
|
filter{255, 0, 255},
|
|
|
|
|
filter{255, 0,255},
|
|
|
|
|
filter{255, 0,255},
|
|
|
|
|
filter{255, 0,255},
|
|
|
|
|
point{0,0,imSize.X,imSize.Y},
|
|
|
|
|
filter{3,0,0},
|
|
|
|
|
}
|
|
|
|
@ -92,6 +95,7 @@ func filterImage(path, fname string) {
|
|
|
|
|
}
|
|
|
|
|
fmt.Print("Saving image \n")
|
|
|
|
|
saveImage(path, fname, imFormat, im)
|
|
|
|
|
fmt.Print("Image saved. Done. \n")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func updateRegister(exp parser.Expression) {
|
|
|
|
@ -179,18 +183,35 @@ func applyToImage(exps []parser.Expression) {
|
|
|
|
|
if exps[1].Variable != "" {
|
|
|
|
|
endY = variables[exps[1].Variable]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
endX = getBoxBound(fil.location.x, endX, variables["WID"], exps[0].Opperator)
|
|
|
|
|
endY = getBoxBound(fil.location.y, endY, variables["HIG"], exps[0].Opperator)
|
|
|
|
|
endY = getBoxBound(fil.location.y, endY, variables["HIG"], exps[1].Opperator)
|
|
|
|
|
|
|
|
|
|
var r,g,b,a int
|
|
|
|
|
var col color.RGBA
|
|
|
|
|
for y := fil.location.y; y <= endY; y++ {
|
|
|
|
|
for x := fil.location.x; x <= endX; x++ {
|
|
|
|
|
r = fil.red.val
|
|
|
|
|
g = fil.green.val
|
|
|
|
|
b = fil.blue.val
|
|
|
|
|
a = fil.alpha.val
|
|
|
|
|
if fil.mode.val != 0 {
|
|
|
|
|
col = im.RGBAAt(x, y)
|
|
|
|
|
// fmt.Printf("Orig: %d, New: %d, Avg: %d\n", col.R, r, avgColor(int(col.R), r))
|
|
|
|
|
r = avgColor(int(col.R), r)
|
|
|
|
|
g = avgColor(int(col.G), g)
|
|
|
|
|
b = avgColor(int(col.B), b)
|
|
|
|
|
a = avgColor(int(col.A), a)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
im.SetRGBA(
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
color.RGBA{
|
|
|
|
|
uint8(fil.red.val),
|
|
|
|
|
uint8(fil.green.val),
|
|
|
|
|
uint8(fil.blue.val),
|
|
|
|
|
uint8(fil.alpha.val),
|
|
|
|
|
uint8(r),
|
|
|
|
|
uint8(g),
|
|
|
|
|
uint8(b),
|
|
|
|
|
uint8(a),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|