mtPaint - Simple paint tutorial

How to do things, solutions, recipes, tutorials
Message
Author
wjaguar
Posts: 359
Joined: Wed 21 Jun 2006, 14:16

#76 Post by wjaguar »

don570 wrote:

Code: Select all

-f/open='/tmp/tmp.svg' undo=1  -image/scale w=x0.5 h=x1.2
When you know the desired size in pixels, it is better to load the SVG pre-scaled, than to scale it afterward; the resulting image will be sharper that way.
Like this:

Code: Select all

-f/open=test.svg width=512 height=256
Or you can set only one dimension, then the other will be scaled as per aspect ratio.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#77 Post by don570 »

Here's a quick way to put a black outline around colored text
using a script...

Here is what the image looks like after saving with transparency="0"
Checkerboard area is the transparent area.
I then saved to clipboard 1 for future use.

I made a light blue image and pasted clipboard 1 inside for the final image.

Image

Code: Select all

#! /bin/bash
# script to outline text

mtpaint --cmd   -f/new w=250 h=150 =24   -e/col a=0 -s/all -e/cut -e/col a=1  -e/freetype font='Nimbus sans L' antialias=0 size=70 back=-1 angle=0  -e/freetype t=mtPaint -e/paste  \(10,10\) -effect/gaussian=3  -f/as=/tmp/temp.png transparency="0"  -s/all -e/copy  -e/'Save Clipboard'/1   -e/col a=6 -s/all -e/cut  -e/'Load Clipboard'/1  -e/paste  -f/as=/tmp/temp.png -f/open=/tmp/temp.png -effect/gaussian=1    -f/as=/tmp/temp.png 

Notes:
-e/paste \(10,10\) ---> I found that slight offset was needed to keep
text in document.

-effect/gaussian=3 ---> this puts the black fringe around text.
This is normally a bad thing :roll: but it is used to put
outline around colored text in this example.

-effect/gaussian=1 ---> this removes jagged edges, however it's not
essential.

Final result..
Image
Last edited by don570 on Sat 12 Mar 2016, 21:40, edited 2 times in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#78 Post by don570 »

Here's a quick way to put a gradient in your text.
Note however that there is a bit of jaggedness because no
gaussian blur was used.

Notes:
-e/paste \(10,10\) ---> I found that a slight offset was needed to keep
the text entirely in document

antialias=0 must be used for the font of text

transparency="0" ---> makes the black of text transparent

You can check what clipboard 1 looks like by making your user home folder show hidden files

-e/"Load Clipboard"/1 -e/paste ---> the paste will set the clipboard in image

A gaussian blur won't work in this example because of the fringe effect
around edges.

Code: Select all

#! /bin/bash
# script to make gradient text

mtpaint --cmd   -f/new w=250 h=150 =24  -e/col a=1 -s/all -e/cut -e/col a=0  -e/freetype font='Nimbus sans L' antialias=0 size=70 back=-1 angle=0  -e/freetype t=mtPaint -e/paste  \(10,10\)  -s/all -e/copy -f/as=/tmp/temptext.png transparency="0" -s/all -e/copy  -e/"Save Clipboard"/1  -e/set grad=1 -e/col a=0 b=115  -e/tool grad \(0,0 0,100\) -e/tool grad: type=lin ext=mirror  -s/all -s/fill  -e/"Load Clipboard"/1  -e/paste -f/save=/tmp/temptext-gradient.png
Image

wjaguar
Posts: 359
Joined: Wed 21 Jun 2006, 14:16

#79 Post by wjaguar »

don570 wrote:-f/as=/tmp/temptext.png transparency="0"
Now that I fixed pref scripting in 3.49.01 :-) the proper way to set transparent color is through pref window: "-i/pref trans=0"
Another route is through layers window, it always worked: "-e/layer trans=0"
No need of a dummy save operation.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#80 Post by don570 »

No need of a dummy save operation.
Good info! Thanks.

__________________________________________


The outline can be made in any color that is available in the palette.
Here are two examples created from one script

Code: Select all

#! /bin/bash
# script to outline text

mtpaint --cmd   -f/new w=250 h=200 =24   -e/col a=1 -s/all -e/cut -e/col a=0 -e/freetype font='Nimbus sans L' antialias=0 size=70 back=-1 angle=0  -e/freetype t=mtPaint -e/paste  \(10,10\) -e/col a=2 -e/freetype t=mtPaint -e/paste  \(10,90\)  -effect/gaussian=3  -f/as=/tmp/temp1.png transparency="1"  -s/all -e/copy  -e/'Save Clipboard'/1   -e/col a=6 -s/all -e/cut  -e/'Load Clipboard'/1  -e/paste  -effect/gaussian=1 -f/as=/tmp/temp2.png 

Image

______________________________


When using the text tool, there are several characters that need protecting
with the back slash

( ) $ ; &

________________________________________
Attachments
temp2.jpg
Final result of running sript
(18.67 KiB) Downloaded 671 times

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

Chrome effect with mtpaint

#81 Post by don570 »

Chrome effect with mtpaint

MtPaint doesn't have a Chrome effect but I found a solution that
results in a high quality chrome effect with no jagged edges!!

- instructions - chrome effect

-launch mtpaint
-use paintbucket to make white document image
-use text tool to put large black characters in image (see below)
-save as png to disk ---> /root/image.png

Image

- use imagemagick 6.9.8 and chrome script
from Fred's site to make a chrome effect
Note: Chrome script must be in executable path



- in terminal type

Code: Select all

chrome -i 100 -n 2 -s 3 -a 135 -e 45 -c white  -b none  -d 1 -B 0 -A off  /root/image.png /root/chrome.png
---> chrome.png is output image

- open output file with mtpaint (see image)

Image


- add a new layer
Layer > New layer (24 bit)

Put it underneath the chrome image. (click on down arrow)

- Turn on gradient tool and put in an interesting gradient with paintbucket
Example has simple linear red-to-black gradient

- Make a composite image (see result below)
Layers > Composite to New Layer

Image

You can now delete the other layers if desired

- Make the grey color transparent

Palette > Palette editor
- use dropper and click on grey portion of image . This makes grey the color 0 (see below for example)

Image

-save composite image as png with transparent color 0
Here is the final image...

Image

The checkerboard indicates transparency.
Note that there is no jagged edges so you can use on any background
and get professional results.
_________________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

Tip : Create a random pattern that repeats without a seam

#82 Post by don570 »

Tip : Create a random pattern that repeats without a seam

using mtpaint

1) Use mtpaint to open an image of a pattern that is fairly random

2)make a selection that is nearly square.


3) Crop command

4) Now make the picture square - The number of pixels must be divisible by 2 (In the example the image is 400 by 400)

Image > Scale Canvas

5) Now resize with an offset of half (see image for an example - half of 400 is 200)


Here is the result ....

6) Use smear brush to eliminate horizontal and vertical seams, but do not alter the edges of image.


7) You can now make a larger document which won't have seams
and will appear random -->
Image > Resize Canvas

________________________________________
Attachments
test400-offset_zpsqkjg3q17.gif
(56.12 KiB) Downloaded 253 times
window_zpskmk4hjlj.PNG
(9.84 KiB) Downloaded 250 times
test400_zpsdy1ljvqv.gif
(43.62 KiB) Downloaded 256 times
Last edited by don570 on Fri 23 Mar 2018, 00:19, edited 4 times in total.

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#83 Post by Pete »

@don570

Nice tuts, please keep them coming.

learnhow2code

#84 Post by learnhow2code »

i was already a fan before i knew it could do stuff like this.

havent found (or looked for) any info about it until i came to this forum. thanks very much.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#85 Post by don570 »

I got the tip from a Blender user video. Photoshop was used
but mtpaint is nearly as good. :lol:
__________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#86 Post by don570 »

Here's the video about pattern painting using Blender.
Well worth watching

https://www.youtube.com/watch?v=7FobUOuISak
_______________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#87 Post by don570 »

I was able to make a default background without using a disk clipboard.
Instead I used the layers feature. (as suggested by Wjaguar)
Should be faster and safer.

Here was the first command...

Code: Select all

mtpaint --cmd  -f/open='/tmp/clock.svg'  -s/all -e/copy -e/'Save Clipboard'/9 -f/new w=1184 h=624 =24   -e/col a=0 -s/all -e/cut -e/col a=9  -e/freetype font='DejaVu Sans' antialias=0 size=70  back=-1 angle=0  -e/freetype t='Fatdog Arm 4' -e/paste  \(470,460\) -effect/gaussian=3  -e/layer trans=0 -effect/gaussian=1  -s/all -e/copy  -e/'Save Clipboard'/8 -e/set  grad=1 -e/col a=0 b=173 -e/tool grad \(300,200 700,500\) -e/tool grad: type=lin ext=mirror     -s/all -e/cut  -e/'Load Clipboard'/8  -e/paste -effect/'Soften ...'=50  -e/'Load Clipboard'/9  -e/paste  \(700,90\)  -f/as=/usr/share/backgrounds/default format=jpeg 

I modified it to the following

Code: Select all

mtpaint --cmd    -f/new w=1184 h=624 =24   -e/set  grad=1 -e/col a=0 b=173 -e/tool grad \(300,200 700,500\) \
      -e/tool grad: type=lin ext=mirror     -s/all -s/"Fill Selection"  \
         -layer/new  -f/open='/tmp/clock.svg'  -s/all -e/copy  -layer/"Remove All Layers"   -e/paste  \(700,90\) \
      -layer/new   -e/col a=9  -e/freetype font='DejaVu Sans' antialias=0 size=70  back=-1 angle=0  -e/freetype t="Fatdog Arm"\
        -e/paste  \(470,460\) -effect/gaussian=3  -e/layer trans=0 -effect/gaussian=1 \
       -layer/"Composite to New Layer" -f/as=/usr/share/backgrounds/default format=jpeg
 

Note that -e/layer trans=0 is used to make the text layer transparent

The clock image is copied to the clipboard and the layer is removed

____________________________________________________
Last edited by don570 on Mon 25 Jul 2016, 19:25, edited 2 times in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#88 Post by don570 »

to create a layer that has the opacity at 66% and black is transparent

Code: Select all

-layer/new  -e/layer opa=66 trans=0
______________________________________________

Brush size can be set which is useful for tools like lines and circles ellipses...
However you will need to experiment for the appropriate number

Code: Select all

 -e/brush=5
_____________________

A line can be made once the size is set. (The size is one pixel by default!)

Code: Select all

-e/tool line \(74,174 612,174\)
Protect the round brackets if you are running a regular script.
Last edited by don570 on Wed 27 Jul 2016, 23:33, edited 4 times in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#89 Post by don570 »

Here some examples of using the script window...
Warning. There can be problems copying scripts from a html page so
if you are having problems then eliminate the line endings and
run the script as just one line.
Also previous settings of mtpaint may affect output. For instance if the gradient tool
is set to 'Reverse' the gradient


First example - Outline a circle

Note that the mtpaint window will show transparency, but since the
output is a jpeg image, there is blackness around the circle.

The round bracket characters don't need protection in the script window.
They do if you are running a regular script.
Note the brush size (which is intended for air brushing).

Code: Select all

-layer/new =24  -e/layer  trans=0 -e/col a=7 -s/all (10,10 100,100) -s/"Fill Ellipse" -e/brush=3  -e/col a=14 -s/all (10,10 100,100) -s/"Outline Ellipse"    -f/as=/root/image format=jpeg
Image
_____________________________________________________

A white triangle can be made by selecting a triangle then cutting (with a=7).
An "outline selection" can be added to make the red outline (a=14).

Note the brush size (which is intended for air brushing)
The output is a png file so transparency is shown with a checker pattern.

Code: Select all

-layer/new =24  -e/layer  trans=0 -e/col a=7 -s/all (10,10 100,100 15,200) -e/cut  -e/brush=3 -e/col a=14 -s/all (10,10 100,100 15,200) -s/"Outline Selection"    -f/as=/root/image2.png
Image
____________________________________________________

To put the shine on the side of a sphere, rather than the middle ---> 2 spheres were created
This required a transparent layer on the background layer.
A third composite layer was created and it was transparent as well so the png file shows transparency.

Code: Select all

-f/new w=313 h=345 =24 -e/col a=1   -s/all  (0,0 90,90) -s/"Fill Ellipse"    -layer/new  -e/layer trans=0 -e/col a=1   -e/set grad=1  -e/tool grad: type=rad ext=none grad=rgb  opac=only -e/tool grad (55,55 75,75) -e/col a=7  b=1  -s/all (0,0 200,200) -s/"Fill Ellipse" -layer/"Composite to New Layer" -e/layer  trans=0  -f/as=/root/image.png



Note that the selection -s/all (0,0 200,200) is chosen to be big enough to fit in both the spheres.

Image

_________________________________________________
Last edited by don570 on Thu 28 Jul 2016, 18:17, edited 2 times in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#90 Post by don570 »

As a comparison with the shine on side here is an example with the shine in middle. It may be simpler to write code but it doesn't look as good.

Code: Select all

-layer/new =24 -e/col a=7  b=1  -e/layer trans=0  -e/set grad=1  -e/tool grad: type=rad ext=none grad=rgb  opac=only -e/tool grad (50,50 70,70)  -e/col a=7   -s/all  (0,0 90,90)   -s/"Fill Ellipse"   -f/as=/root/image2.png
Image
_____________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

mtpaint lines

#91 Post by don570 »

Here are some examples using the line command...
Vertical or horizontal lines are simple and there is no jaggedness

Code: Select all


-e/brush=3 -e/tool line (10,10 10,100) -s/all (30,10 38,100) -e/cut

Note that the line tool makes the line have rounded ends no matter the brush
size setting. Conclusion the cut method is better and simple to code.

Image

_________________________________________________________


...But there is a problem when the line is at an angle. Jaggedness appears in both methods, but it appears worse in the cut method,
and the cut method is difficult (there's no simple rule to derive the coordinates)

Code: Select all

-e/brush=3   -e/tool line (25,25 50,85)  -s/all (40,26 45,23 96,80 90,86)  -e/cut

Image

_____________________________________________________

It is tempting to use the Free Rotate command to rotate a cut area.

Code: Select all

-layer/new  -s/all (30,10 38,100) -e/cut  -e/col a=0  -image/rotate=45
The result looks nice, because there is a slight antialiasing applied by mtpaint.
However this antialiasing causes problems when using the lasso tool
and pasting the line into another document.
I'll explain in next post.

Image
________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

alpha blend command in mtpaint

#92 Post by don570 »

If the background is white the rotate command still gives good results.
(See image below)

Code: Select all

-layer/new -e/col a=7   -s/all  -s/fill   -e/col a=1  -s/all (30,10 38,100) -e/cut  -e/col a=7  -image/rotate=45
Image

However in a more practical example the line must be lassoed and transfered to another document.

Here is the result magnified several times. See the black fringe affect.
Image


So here is the code that will avoid this fringe affect. It uses alpha blend,
one of the features of mtpaint.
gaussian=1 is fine to get rid of jagged edges.

Code: Select all

-layer/new -s/all (30,10 38,100) -e/cut  -e/col a=0  -image/rotate=45 -s/all  -s/"Lasso Selection"   -layer/new =24  -e/paste (10,10) -effect/gaussian=1 -s/all  -s/"Lasso Selection" -layer/new =24 -e/col a=7  -s/all  -s/"Fill Selection"  -e/col  a=1  b=0 -s/'Alpha Blend'    -e/paste   -f/as=/root/image.png
Code explanation:
- a gaussian blur can only be done with 24 bits of color so start with the
correct document
-Red horizontal line is created with cut command (or fill command if you prefer)
- a=0 ( i.e. black) is needed before rotation to fill triangle edges of rotated document.

- entire document is selected and then lassoed to clipboard.

-pasted to new layer (i.e. a new document) and jaggedness is removed with
the gaussian effect (gaussian=1 )

-red line lassoed again . It is in the clipboard again.

I made a final document (a white image)
Note I filled the document with the color white (a=7).

- -e/col a=1 b=0 was needed for the correct alpha blend procedure in this example
---> Because it was a red line with some black fringing.

- the alpha blend command is applied then finally the paste command.

Image
____________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#93 Post by don570 »

Tip to make stars and other objects in mtpaint

The vertices are needed when using a script, so here is what I suggest.

Brush size ---> 1 pixel
Make a square selection with selection tool
Make a circle --->

Selection -> Outline Ellipse

Paint marks an equal space apart along circle circumference(see image)

Image

Use line tool to connect points (See image)

Image

Open text editor and note the vertices
as you hover your mouse over mtpaint window
Coordinates can be read from bottom left of mtpaint window.
Here is the results:

498 239
478 176
526 139
465 141
447 83
425 139
366 144
413 178
392 239
443 201

Now you construct the script commands

Code: Select all

-layer/new -s/all (498,239 478,176 526,139 465,141 447,83 425,139 366,144 413,178 392,239 443,201) -s/fill


Image

For best results you should be using 24 bit color and then doing a gaussian blur
after constructing the star

Code: Select all

-layer/new =24 -s/all (498,239 478,176 526,139 465,141 447,83 425,139 366,144 413,178 392,239 443,201) -s/fill -effect/gaussian=1
Scale document if you want a different size. Then lasso and copy to a final document.
_______________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

Scaling and tiling in mtpaint

#94 Post by don570 »

Scaling and tiling in mtpaint

There are two useful commands that should be noted.
The following command will scale the image by 2. Actually height h
is scaled by 2 . The width w is assumed to be scaled by 2 as well.

Code: Select all

-layer/new -image/scale h=x2
To make the object smaller

Code: Select all

-layer/new -image/scale h=x.25
_________________________________________________________

To resize the document i.e. the layer and tile it at the same time
In this example both height and width are expanded with tiles.
There will be 3x3=9 tiles in total.

Code: Select all

-i/resize =tile h=x3
Now for the final example...

The star is created in 24 bit layer and then made smaller and slightly blurred.
It is lassoed and pasted (using alpha blend method to avoid a black outline)
into the centre of a small white document which is then tiled so
that 3x3 stars are the result.

Code: Select all

-layer/new =24 -s/all (498,239 478,176 526,139 465,141 447,83 425,139 366,144 413,178 392,239 443,201) -s/fill -effect/gaussian=1  -image/scale h=x.25  -s/all  -s/"Lasso Selection" -layer/new     w=50 h=50    =24  -e/col a=7  -s/all  -s/"Fill Selection" -e/col  a=1  b=0 -s/'Alpha Blend' -e/"Paste to Centre" -i/resize =tile h=x3
Image
________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

a selection from GIMP

#95 Post by don570 »

When pasting a selection from GIMP into mtpaint....

The best way is to go to the top menu
Layer > New layer

and from the options choose 'Clipboard'.

This will create a new layer above your old layer.

___________________________________________

Post Reply