func main() {
	b := raster.NewBitmap(400, 300)
	b.FillRgb(0xffefbf)
	b.Bézier3Rgb(20, 200, 700, 50, -300, 50, 380, 150, raster.Rgb(0x3f8fef))
	if err := b.WritePpmFile("bez3.ppm"); err != nil {
		fmt.Println(err)
	}
}
func main() {
	width := sep * 11 / 6
	height := sep * 4 / 3
	b = raster.NewBitmap(width, height)
	b.Fill(raster.Pixel{255, 255, 255})
	dragon(14, 0, 1, sep, sep/2, sep*5/6)
	b.WritePpmFile("dragon.ppm")
}
func main() {
	b := raster.NewBitmap(400, 300)
	b.FillRgb(0xdfffef)
	b.Bézier2Rgb(20, 150, 500, -100, 300, 280, raster.Rgb(0x3f8fef))
	if err := b.WritePpmFile("bez2.ppm"); err != nil {
		fmt.Println(err)
	}
}
func main() {
	b := raster.NewBitmap(400, 300)
	b.FillRgb(0xffdf20) // yellow
	// large circle, demonstrating clipping to image boundaries
	b.CircleRgb(300, 249, 200, 0xff2020) // red
	if err := b.WritePpmFile("circle.ppm"); err != nil {
		fmt.Println(err)
	}
}
func main() {
	b := raster.NewBitmap(400, 300)
	b.FillRgb(0xdfefff)
	blue := raster.Rgb(0x8fcfff)
	b.LineRgb(7, 12, 307, 122, blue)
	b.LineRgb(177, 12, 127, 222, blue)
	err := b.WritePpmFile("bresenham.ppm")
	if err != nil {
		fmt.Println(err)
	}
}
func main() {
	b := raster.NewBitmap(400, 300)
	// a little extravagant, this draws a design of dots and lines
	b.FillRgb(0xc08040)
	for i := 0; i < 2000; i++ {
		b.SetPxRgb(rand.Intn(400), rand.Intn(300), 0x804020)
	}
	for x := 0; x < 400; x++ {
		for y := 240; y < 245; y++ {
			b.SetPxRgb(x, y, 0x804020)
		}
		for y := 260; y < 265; y++ {
			b.SetPxRgb(x, y, 0x804020)
		}
	}
	for y := 0; y < 300; y++ {
		for x := 80; x < 85; x++ {
			b.SetPxRgb(x, y, 0x804020)
		}
		for x := 95; x < 100; x++ {
			b.SetPxRgb(x, y, 0x804020)
		}
	}

	// pipe logic
	c := exec.Command("cjpeg", "-outfile", "pipeout.jpg")
	pipe, err := c.StdinPipe()
	if err != nil {
		fmt.Println(err)
		return
	}
	err = c.Start()
	if err != nil {
		fmt.Println(err)
		return
	}
	err = b.WritePpmTo(pipe)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = pipe.Close()
	if err != nil {
		fmt.Println(err)
	}
}