Example #1
0
func SingleTest() {

	for k, v := range sortway {
		c := Coordinate.NewCoordinateSize(cx0, cy0, cx1, cy1)
		node := testTime(v, testDataSorted, false)
		r := *Coordinate.NewRgba(0, 0, 255, 255) //blue
		c.FoldLine(node, r)
		node = testTime(v, testDataReversed, false)
		r = *Coordinate.NewRgba(255, 0, 0, 255) //red
		c.FoldLine(node, r)
		largest = 512
		node = testTime(v, testDataRandom, true)
		r = *Coordinate.NewRgba(0, 255, 0, 255) //green
		c.FoldLine(node, r)

		imgfile, _ := os.Create(fmt.Sprintf("%s.png", k))
		defer imgfile.Close()

		// 以PNG格式保存文件
		err := png.Encode(imgfile, c.Img)
		if err != nil {
			log.Fatal(err)
		}
	}

}
Example #2
0
//the argument is test way
func BroadContrast(ty int) {
	fn := testDataSorted
	rd := false
	var imgname string
	switch ty {
	case 0:
		fn = testDataSorted
		imgname = "testDataSorted"
	case 1:
		fn = testDataReversed
		imgname = "testDataReversed"
	case 2:
		fn = testDataRandom
		imgname = "testDataRandom"
		rd = true
	}

	c := Coordinate.NewCoordinateSize(cx0, cy0, cx1, cy1)
	var r Coordinate.Rgba
	for k, v := range sortway {

		node := testTime(v, fn, rd)
		switch k {
		case "BubbleSort":
			r = *Coordinate.NewRgba(0, 0, 255, 255) //blue
		case "BucketSort":
			r = *Coordinate.NewRgba(255, 0, 0, 255) //red
		case "HeapSort":
			r = *Coordinate.NewRgba(0, 255, 0, 255) //green
		case "InsertSort":
			r = *Coordinate.NewRgba(255, 255, 0, 255) //yellow
		case "MergeSort":
			r = *Coordinate.NewRgba(112, 128, 144, 255) //gray
		case "QuickSort":
			r = *Coordinate.NewRgba(255, 0, 255, 255) //purple
		case "SelectSort":
			r = *Coordinate.NewRgba(255, 105, 180, 255) //pink
		case "ShellSort":
			r = *Coordinate.NewRgba(0, 0, 0, 255) //green

		}

		c.FoldLine(node, r)
	}

	imgfile, _ := os.Create(fmt.Sprintf("%s.png", imgname))
	defer imgfile.Close()

	// 以PNG格式保存文件
	err := png.Encode(imgfile, c.Img)
	if err != nil {
		log.Fatal(err)
	}
}