diff --git a/main.go b/main.go index 33300f6..28a135a 100644 --- a/main.go +++ b/main.go @@ -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), }) } } diff --git a/newtest.frs b/newtest.frs new file mode 100644 index 0000000..731efeb --- /dev/null +++ b/newtest.frs @@ -0,0 +1,7 @@ +MOD 1 + +BEG 25 + COL 255:0:0:200 + APY +10:+HIG + LOC +20:+0 +END diff --git a/test.frs b/test.frs index e3b872f..a88e237 100644 --- a/test.frs +++ b/test.frs @@ -4,14 +4,19 @@ APH 255 RED 100 BLU 100 GRN 100 -# This loop should create a bunch of vertical lines -BEG 50 - RED +23 - BLU -81 - GRN *27 - APH -5 - APY +5:HIG - LOC +20:+0 +REG WID +REG /20 +REG /4 +LOC +1:+1 + +BEG 100 + COL +23:-81:*27:-0 + APY +3:+3 + APY +1:+HIG + LOC +0:+4 + APY +WID:+0 + LOC +0:-4 + LOC +REG:*24 END