예제 #1
0
func BenchmarkExec(b *testing.B) {
	for i := 0; i < b.N; i++ {
		canvas := figure.NewCanvas(canvasFile)
		pattern := figure.NewFigure(patternFile)
		canvas.Search(pattern)
		canvas.GetMaxSize()
	}
}
예제 #2
0
func main() {
	flag.Parse()

	filepath := flag.Arg(0)

	if filepath == "" {
		fmt.Fprintln(os.Stderr, "usage: pattern pattern_file")
		return
	}

	canvas := figure.NewCanvas(canvasFile)
	pattern := figure.NewFigure(filepath)
	resX, resY := canvas.Search(pattern)
	fmt.Printf("(%d, %d), ", resX, resY)
	fmt.Printf("(%d, %d), ", resX+pattern.Width, resY)
	fmt.Printf("(%d, %d), ", resX, resY+pattern.Height)
	fmt.Printf("(%d, %d)\n", resX+pattern.Width, resY+pattern.Height)

	figure := canvas.GetMaxSize()
	fmt.Printf("%dpx ", figure.Size)
	fmt.Printf("(%d, %d)\n", figure.X, figure.Y)
}