top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Ubuntu: Drawing vector graphics using a command line

0 votes
389 views

Anyone know of a tool to create SVG files (or similar) using some kind of macro or command line?
For instance, if I want to draw several lines start starts at the same point, have the same length but different angles (this example is written in some kind of Basic looking pseudo code):

x=150
y=100
length=100
drawline x,y,length,0
drawline x,y,length,1.4
drawline x,y,length,2,8
drawline x,y,length,4.2
drawline x,y,length,5.6
drawline x,y,length,7.0

Or maybe even better; something like this:

x=150
y=100
length=100
For Angle=0 To 180 Step 1.4
 drawline x,y,length,angle
Next Angle

Another acceptable approach would be:

xStart=150
yStart=100
Length=100
For Angle=0 To 180 Step 1.4
xEnd=xStart+Length*sin(Angle*π/180)
yEnd=xStart+Length*cos(Angle*π/180)
  drawline xStart,yStart,xEnd,yEnd
Next Angle

I have had a quick look at Inkscape but I couldnt find any kind of command line or macro programming IDE there.

posted Sep 20, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Two suggestions.

First, if you can tolerate encapsulated postscript, you can use LaTeX. The following is an example I used recently:

documentclass{article}
usepackage{mathptmx}

%% Pictures
usepackage{pst-pdf,pst-node}

begin{document}
begin{pspicture}[showgrid=false](0,0)(2,2)
 psset{arrows=->}
 rput(0.529,0.353){dotnode{V1}}
 rput(1.470,0.353){dotnode{V2}}
 rput(1.712,1.247){dotnode{V3}}
 rput(1.000,1.800){dotnode{V4}}
 rput(0.239,1.247){dotnode{V5}}

 ncline[linestyle=dashed]{V1}{V2}
 ncline{V3}{V2}
 ncline{V4}{V3}
 ncline{V5}{V4}
 ncline{V1}{V5}
end{pspicture}
end{document}

This draws a pentagon with dashed and solid lines and nodes at the vertices. To convert to pdf use estopdf.

I used to write raw PostScript. But I rarely do this now that the LaTeX PSTricks packages do what I want for simple graphics and R can handle the really complex stuff.

Second, IIRC SVG is a language you can just write. Have a look at some of these examples: http://www.w3schools.com/svg/svg_examples.asp. I have written some SVGs several years back, but usually I need pdf or eps
format nowadays.

answer Sep 20, 2015 by anonymous
Similar Questions
+1 vote

I am running Ubuntu 14.04. I booted up this morning and got that Ubuntu was running in low graphics mode. I have no mouse. I press enter. It then gives me a box that has several options. The top one, run in low graphics mode is marked. The keyboard is now dead. I cant get past this box I have tried several times with the same result. I didnt make any changes last night, nor were there any updates.

...