<commit_before>// 10 june 2014

package ndraw

import (
	"fmt"
	"image"
	"testing"
	"github.com/andlabs/ui"
)

type areaHandler struct {
	img		*image.RGBA
}
func (a *areaHandler) Paint(r image.Rectangle) *image.RGBA {
	return a.img.SubImage(r).(*image.RGBA)
}
func (a *areaHandler) Key(ke ui.KeyEvent) bool {
	return false
}
func (a *areaHandler) Mouse(me ui.MouseEvent) {}

var w ui.Window

func myMain() {
	fonts := ListFonts()
	for _, font := range fonts {
		fmt.Printf("%#v\n", font)
	}
	i := NewImage(320, 240)
	defer i.Close()
	b := NewBrush(BrushSpec{
		R:			0,
		G:			128,
		B:			0,
		A:			0xFF,
	})
	f := NewFont(FontSpec{
		Family:	"Helvetica",
		Size:		12,
		Bold:		true,
	})
	i.Text("hello, world", 100, 20, f, nil, b)
	b.Close()
	p := NewPen(PenSpec{
		R:			128,//255, - TODO GDI AlphaBlend() actually produces gray for this invalid combination while cairo and Quartz do not (!!!)
		G:			0,
		B:			0,
		A:			128,
		Line:			Solid,
		Thickness:	3,
	})
	i.Line(4, 4, 316, 236, p)
	i.Line(100, 20, 101, 21, p)
	p.Close()
	p = NewPen(PenSpec{
		R:			0,
		G:			0,
		B:			255,
		A:			255,
		Line:			Solid,
		Thickness:	2,
	})
	wid, ht := i.TextSize("hello, world", f)
	i.Line(100, 20 + ht + 10, 100 + wid, 20 + ht + 10, p)
	i.Line(100 + wid + 10, 20, 100 + wid + 10, 20 + ht, p)
	p = NewPen(PenSpec{
		R:			0,
		G:			0,
		B:			255,
		A:			255,
		Line:			Solid,
		Thickness:	1,
	})
	i.Line(100, 20 + ht, 100 + wid, 20 + ht, p)
	i.Line(100 + wid, 20, 100 + wid, 20 + ht, p)
	i.Line(30, 200, 50, 240, p)
	p.Close()
	f.Close()
	ui.Do(func() {
		w = ui.NewWindow("Test", 320, 240, ui.NewArea(320, 240, &areaHandler{
			img:		i.Image(),
		}))
		w.OnClosing(func() bool {
			ui.Stop()
			return true
		})
		w.Show()
	})
}

func init() {
	go myMain()<commit_msg>Fixed diagonal line test.<commit_after>// 10 june 2014

package ndraw

import (
	"fmt"
	"image"
	"testing"
	"github.com/andlabs/ui"
)

type areaHandler struct {
	img		*image.RGBA
}
func (a *areaHandler) Paint(r image.Rectangle) *image.RGBA {
	return a.img.SubImage(r).(*image.RGBA)
}
func (a *areaHandler) Key(ke ui.KeyEvent) bool {
	return false
}
func (a *areaHandler) Mouse(me ui.MouseEvent) {}

var w ui.Window

func myMain() {
	fonts := ListFonts()
	for _, font := range fonts {
		fmt.Printf("%#v\n", font)
	}
	i := NewImage(320, 240)
	defer i.Close()
	b := NewBrush(BrushSpec{
		R:			0,
		G:			128,
		B:			0,
		A:			0xFF,
	})
	f := NewFont(FontSpec{
		Family:	"Helvetica",
		Size:		12,
		Bold:		true,
	})
	i.Text("hello, world", 100, 20, f, nil, b)
	b.Close()
	p := NewPen(PenSpec{
		R:			128,//255, - TODO GDI AlphaBlend() actually produces gray for this invalid combination while cairo and Quartz do not (!!!)
		G:			0,
		B:			0,
		A:			128,
		Line:			Solid,
		Thickness:	3,
	})
	i.Line(4, 4, 316, 236, p)
	i.Line(100, 20, 101, 21, p)
	p.Close()
	p = NewPen(PenSpec{
		R:			0,
		G:			0,
		B:			255,
		A:			255,
		Line:			Solid,
		Thickness:	2,
	})
	wid, ht := i.TextSize("hello, world", f)
	i.Line(100, 20 + ht + 10, 100 + wid, 20 + ht + 10, p)
	i.Line(100 + wid + 10, 20, 100 + wid + 10, 20 + ht, p)
	p = NewPen(PenSpec{
		R:			0,
		G:			0,
		B:			255,
		A:			255,
		Line:			Solid,
		Thickness:	1,
	})
	i.Line(100, 20 + ht, 100 + wid, 20 + ht, p)
	i.Line(100 + wid, 20, 100 + wid, 20 + ht, p)
	i.Line(30, 200, 70, 240, p)
	p.Close()
	f.Close()
	ui.Do(func() {
		w = ui.NewWindow("Test", 320, 240, ui.NewArea(320, 240, &areaHandler{
			img:		i.Image(),
		}))
		w.OnClosing(func() bool {
			ui.Stop()
			return true
		})
		w.Show()
	})
}

func init() {
	go myMain()
{'fraction_non_alphanumeric': 0.18374858437146094, 'fraction_numerical': 0.08097395243488109, 'mean_word_length': 2.75451647183847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3157698', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1659, 'n_words': 438}