Some like it in writing

Log-in or register.

Some like it in writing

Published by on August 20th 2011.

It is the year 2011 and the brand new RW Paint is going to get a command line interface. Excited? No? Too bad. Anyway, this magic command line will allow you to be more precise when using drawing tools and it will help you when you need to repeatedly draw the same or similar objects.

I know, it is hard to imagine and a picture is worth a thousand words. Here is one:

rsrc/toolcmdline.png image

As you can see, I am drawing a poly-line using the LINE tool. While I am drawing, the small text area near the bottom of the window displays a textual representation of my current drawing tool state. For your convenience, I have copied it here:

DrawTool.LINE(Document, 15, "JROUND", 47.5, 222.5, 47.5, 100.5, 127.5, 27.5, 207.5, 100.5, 207.5, 222.5, "CLOSE");

While working with a drawing tool (moving or adding points to a poly-line in my case), the text is continuously updated. The opposite is true as well. If the text in the text box is updated, the change is immediately shown on the canvas.

The command line can help you with:

  • Accuracy - you can type exact coordinates after you have drawn a rough shape with the mouse.
  • Repetitions - you can copy the command to the clipboard, possibly save it to an external text file and later paste it back to draw exactly the same shape (this could be very handy with the Projected shadow tool to help you create exactly the same shadows on multiple images).
  • Scripting - more on this in a bit.

Format of the draw commands

Currently, the command line can display the draw command in 2 modes: Simple and Script. There are not many differences and I am unsure which one will be the default one. The command shown above was using the Script mode, let's look at the same command in Simple mode:

LINE 15, "JROUND", 47.5, 222.5, 47.5, 100.5, 127.5, 27.5, 207.5, 100.5, 207.5, 222.5, "CLOSE"

The Script mode contains a bit of syntactic junk (DrawTool. Document, parentheses, semicolon), but thanks to this junk, the command can be directly used in a script. You can for example use the Projected shadow tool, copy the command, go to layer styles, select the JavaScript operation and paste the command there to use projected shadow as a layer style.

A little bonus

Last year, I have added a feature that allows you to use simple expressions instead of constants in some places (like image effect configuration windows). The good news is, these expressions can be used on the command line as well.

If you need to place a line 27 pixels from the right edge of a 256x256 pixels image, you can either do the math in your head or you can simply write 256-27 instead of 229.

What do these numbers and letters mean?

How do you find out what are the script names of the drawing tools and what parameters do they accept? Experiment! Or have a look at the drawing tool list. Some tools also have sections on scripting with examples.

For now let's analyze our command:

DrawTool.LINE(Document, 15, "JROUND", 47.5, 222.5, 47.5, 100.5, 127.5, 27.5, 207.5, 100.5, 207.5, 222.5, "CLOSE");

DrawTool and Document are part of the syntactic junk we can safely ignore.
LINE is the name of the line tool - all tool names use upper case letters.
15 is the line width.
"JROUND" means use round joins.
The numbers are pairs of x and y coordinates of the polyline points.
"CLOSE" directs the tool to connect the last point with the first one.

Be aware that not every tool is usable from script. For example pencil, brush or lasso need too many coordinates and it would not be practical to control them from the command line.

It's crazy!

Fortunately, there is a way to turn it off and work just like before. It may even be the default in the new Paint.

Vlasta's blog RSS feed

Recent comments

user icon Anonymous on December 11th 2011

That's pretty neat. It reminds me of old Generic CAD 6 (and newer AutoCAD R14) I played around with on my dad's computer, where drafting was often a hybrid interleaved operation of mouse and keyboard input; and I've never seen this usefulness in a raster image editor yet. (Dwayne from Washington)

user icon Anonymous
Select background
I wish there were...
What about ICL files?
Vista & Win 7 icons