From 59aa41ad707a814ea7145248c52f6f16b1c895d3 Mon Sep 17 00:00:00 2001 From: trustable-code Date: Sat, 1 Jul 2017 14:24:18 +0200 Subject: first public preview version --- examples/example_11_image_processing_cli.nim | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 examples/example_11_image_processing_cli.nim (limited to 'examples/example_11_image_processing_cli.nim') diff --git a/examples/example_11_image_processing_cli.nim b/examples/example_11_image_processing_cli.nim new file mode 100755 index 0000000..ec0f263 --- /dev/null +++ b/examples/example_11_image_processing_cli.nim @@ -0,0 +1,47 @@ +# This example shows how to do image processing without GUI + +import nigui + +app.init() + +var image1 = newImage() +image1.loadFromFile("example_01_basic_app.png") +# Reads the file and holds the image as bitmap in memory + +var image2 = newImage() +image2.resize(200, 200) + +let canvas = image2.canvas +# A shortcut + +canvas.areaColor = rgb(30, 30, 30) # dark grey +canvas.fill() +# Fill the whole area + +canvas.setPixel(0, 0, rgb(255, 0, 0)) +# Modifies a single pixel + +canvas.areaColor = rgb(255, 0, 0) # red +canvas.drawRectArea(10, 10, 30, 30) +# Draws a filled rectangle + +canvas.lineColor = rgb(255, 0, 0) # red +canvas.drawLine(60, 10, 110, 40) +# Draws a line + +let text = "Hello World!" +canvas.textColor = rgb(0, 255, 0) # lime +canvas.fontSize = 20 +canvas.fontFamily = "Arial" +canvas.drawText(text, 10, 70) +# Outputs a text + +canvas.drawRectOutline(10, 70, canvas.getTextWidth(text), canvas.getTextLineHeight()) +# Draws a rectangle outline + +canvas.drawImage(image1, 10, 120) +# Draws an image in original size + +image2.saveToPngFile("out.png") +# Save the image as PNG file + -- cgit v1.2.3