diff options
author | Araq <rumpf_a@web.de> | 2011-11-19 15:45:51 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-11-19 15:45:51 +0100 |
commit | a274f3bf5be3fc35f1538e5aab0e32fb9ed2ff82 (patch) | |
tree | 95dc5bf7fe3716a3ab266f78094fccce38c94ccf /tests/compile/tconvert.nim | |
parent | d0772feb08baaea12bfdad0a7c20a41733f977bd (diff) | |
download | Nim-a274f3bf5be3fc35f1538e5aab0e32fb9ed2ff82.tar.gz |
got rid of 'accept' dir in the tests
Diffstat (limited to 'tests/compile/tconvert.nim')
-rwxr-xr-x | tests/compile/tconvert.nim | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/compile/tconvert.nim b/tests/compile/tconvert.nim new file mode 100755 index 000000000..f96cf2688 --- /dev/null +++ b/tests/compile/tconvert.nim @@ -0,0 +1,38 @@ +import + Cairo + +converter FloatConversion64(x: int): float64 = return toFloat(x) +converter FloatConversion32(x: int): float32 = return toFloat(x) +converter FloatConversionPlain(x: int): float = return toFloat(x) + +const width = 500 +const height = 500 +const outFile = "CairoTest.png" + +var surface = Cairo.ImageSurfaceCreate(CAIRO.FORMAT_RGB24, width, height) +var ç = Cairo.Create(surface) + +ç.SetSourceRGB(1, 1, 1) +ç.Paint() + +ç.SetLineWidth(10) +ç.SetLineCap(CAIRO.LINE_CAP_ROUND) + +const count = 12 +var winc = width / count +var hinc = width / count +for i in 1 .. count-1: + var amount = i / count + ç.SetSourceRGB(0, 1 - amount, amount) + ç.MoveTo(i * winc, hinc) + ç.LineTo(width - i * winc, height - hinc) + ç.Stroke() + + ç.SetSourceRGB(1 - amount, 0, amount) + ç.MoveTo(winc, i * hinc) + ç.LineTo(width - winc, height - i * hinc) + ç.Stroke() + +echo(surface.WriteToPNG(outFile)) +surface.Destroy() + |