Skip to content

Commit

Permalink
Renamed option -m to -c and changed semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
borud committed May 26, 2019
1 parent 9911ed1 commit 45d4751
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -29,7 +29,7 @@ To install
- **`-t`** : luma threshold (0.0 to 1.0)
- **`-l`** : use BT.701 luma function instead of BT.601 to give more
weight to red and blue
- **`-m`** : create monochrome
- **`-c`** : use average color for area rather than just black (default true)

Example usages

Expand Down
8 changes: 4 additions & 4 deletions main.go
Expand Up @@ -32,7 +32,7 @@ var (
outputFile = flag.String("o", "", "Output file")
boxSize = flag.Int("b", 50, "Box size for dots")
lumaThreshold = flag.Float64("t", 1.0, "Luma threshold - don't draw dots above this luminescence value. Value from 0.0 to 1.0")
mono = flag.Bool("m", false, "Set image to monochrome")
color = flag.Bool("c", true, "Use average color for area rather than just black")
bt701 = flag.Bool("l", false, "Use BT.701 instead of BT.601 for luma calculations")
)

Expand Down Expand Up @@ -71,7 +71,7 @@ func lumaBT601(r uint32, g uint32, b uint32) float64 {
// makeDots creates dots whose diameter is proportional to the
// luminance and color is the average color of the area in the image
// they represent.
func makeDots(img image.Image, boxSize int, lumaThreshold float64, mono bool, bt709 bool, outputFileName string) {
func makeDots(img image.Image, boxSize int, lumaThreshold float64, color bool, bt709 bool, outputFileName string) {
// Create the output file
svgFile, err := os.Create(outputFileName)
if err != nil {
Expand Down Expand Up @@ -138,7 +138,7 @@ func makeDots(img image.Image, boxSize int, lumaThreshold float64, mono bool, bt
continue
}

if mono {
if color {
canvas.Circle((x*boxSize)+boxHalf, (y*boxSize)+boxHalf, int((1.0-luma)*float64(boxHalf)), "fill:black;stroke:none")
} else {
canvas.Circle((x*boxSize)+boxHalf, (y*boxSize)+boxHalf, int((1.0-luma)*float64(boxHalf)), fmt.Sprintf("fill:#%02x%02x%02x;stroke:none", rSum, gSum, bSum))
Expand Down Expand Up @@ -169,5 +169,5 @@ func main() {
outputFile = &fn
}

makeDots(img, *boxSize, *lumaThreshold, *mono, *bt701, *outputFile)
makeDots(img, *boxSize, *lumaThreshold, *color, *bt701, *outputFile)
}

0 comments on commit 45d4751

Please sign in to comment.