github.com/ajstarks/decksh (go): Package decksh is a little language that generates deck markup assignments  ```decksh``` is a domain-specific language (DSL) for generating [```deck```](https://github.com/ajstarks/deck/blob/master/README.md) markup.  ## References and Examples  * [```decksh``` overview](https://speakerdeck.com/ajstarks/decksh-a-little-language-for-decks)  * [```decksh``` object reference](https://speakerdeck.com/ajstarks/decksh-object-reference)  * [Repository of decksh projects and visualizations](https://github.com/ajstarks/deckviz)  ## Package use  There is a simple method ```Process``` that reads decksh commands from an ```io.Reader``` and writes deck markup to an  ```io.Writer```, returning an error.  ## Running  This repository also contains ```cmd/decksh```, a client decksh command:  ```decksh``` reads from the specified input, and writes deck markup to the specified output destination:  Typically, ```decksh``` acts as the head of a rendering pipeline:  ## Example input  This deck script:  Text, font, color, caption and link arguments follow Go convetions (surrounded by double quotes).  Colors formats are:  * rgb format "rgb(n,n,n)", for example "```"rgb(128,0,128)"``` * hex "#rrggbb", for example ```"#aa00aa"```, or * [SVG color names](https://www.w3.org/TR/SVG11/types.html#ColorKeywords).  Color gradients (used for slide backgrounds and rectangle and square fills) are specified as color1/color2/percent, for example, ```"blue/white/90"```  Coordinates, dimensions, scales and opacities are floating point numbers ranging from from 0-100 (representing percentages of the canvas width and percent opacity).  Some arguments are optional, and if omitted defaults are applied (black for text, gray for graphics, 100% opacity).  Canvas size and image dimensions are in pixels.  ## Begin or end a deck.  ## Begin, end a slide with optional background and text colors.  ## Specify the size of the canvas.  ## Simple assignments  ```id=<number>``` defines a constant, which may be then subtitited. For example:  ## Assignment operations  ```id+=<number>``` increment the value of ```id``` by ```<number>```  ```id-=<number>``` decrement the value of ```id``` by ```<number>```  ```id*=<number>``` multiply the value of ```id``` by ```<number>```  ```id*=<number>``` divide the value of ```id``` by ```<number>```  ## Binary operations  Addition ```id=<id> + number or <id>```  Subtraction ```id=<id> - number or <id>```  Muliplication ```id=<id> * number or <id>```  Division ```id=<id> / number or <id>```  ## Coordinate assignments  Assign (x,y) coordinates to the specified identifier. The x coordinate is ```id_x``` and the y coordinate is ```id_y```. The expression with the parentheses may be a constant, variable or binary expression.  This code:  makes this:  ## Polar Coordinates  Return the polar coordinate given the center at ```(cx, cy)```, radius ```r```, and angle ```theta``` (in degrees)  ## Polar Coordinates (composite)  Return the polar coordinates ```(p_x)``` and ```(p_y)``` given the  center at ```(cx, cy)```, radius ```r```, and angle ```theta``` (in degrees)  ## Area  return the circular area, ```a``` for the diameter ```d```.  ## Formatted Text  Assign a string variable with formatted text (using package fmt floating point format strings)  ## Random Number  assign a random number in the specified range  ## Square Root  return the square root of the number of expression (```id``` or binary operation)  ## Mapping  For value ```v```, map the range ```vmin-vmax``` to ```min-max```.  ## Loops  Loop over ```statements```, with ```x``` starting at ```begin```, ending at ```end``` with an optional ```increment``` (if omitted the increment is 1). Substitution of ```x``` will occur in statements.  Loop over ```statements```, with ```x``` ranging over the contents of items within ```[]```. Substitution of ```x``` will occur in statements.  Loop over ```statements```, with ```x``` ranging over the contents ```"file"```. Substitution of ```x``` will occur in statements.  ## Include decksh markup from a file  places the contents of ```"file"``` inline.  ## Functions  Functions have a defined ```name``` and arguments, and are specifed with statements between the  ```def``` and ```edef``` keywords  ## Importing function defintions  Functions may be imported once, and then called by name.  For example, given a file ```redcircle.dsh```:  which is referenced:  Functions may also be called with the ```func``` keyword:  For example, given a file "ftest.dsh"  calling the function:  produces:  ## Data: Make a file  makes a file named ```foo.d``` with the lines between ```data``` and ```edata```.  ## Grid: Place objects on a grid  The first file argument (```"file.dsh"``` above) specifies a file with decksh commands; each item in the file must include the arguments "x" and "y". Normal variable substitution occurs for other arguments. For example if the contents of ```file.dsh``` has six items:  The line:  creates two rows: three circles and then three squares  ```x, y``` specify the beginning location of the items, ```xskip``` is the horizontal spacing between items. ```yinternal``` is the vertical spacing between items and ```limit``` the the horizontal limit. When the ```limit``` is reached, a new row is created.  ## Text  Left, centered, end, or block-aligned text or file contents (```x``` and ```y``` are the text's reference point), with  optional font ("sans", "serif", "mono", or "symbol"), color and opacity.  Text rotated along the specified angle (in degrees)  Text on an arc centered at ```(x,y)```, with specified radius, between begin and ending angles (in degrees). if the beginning angle is less than the ending angle the text is rendered counter-clockwise. if the beginning angle is greater than the ending angle, the text is rendered clockwise.  Place the contents of "filename" at (x,y). Place the contents of "filename" in gray box, using a monospaced font.  ## Images  Plain and captioned, with optional scales, links and caption size. ```(x, y)``` is the center of the image, and ```width``` and ```height``` are the image dimensions in pixels.  ## Lists  (plain, bulleted, numbered, centered). Optional arguments specify the color, opacity, line spacing, link and rotation (degrees)  ### list items, and ending the list  ## Graphics  Rectangles, ellipses, squares, circles: specify the center location ```(x, y)``` and dimensions ```(w,h)``` with optional color and opacity. The default color and opacity is gray, 100%.  In the case of the ```acircle``` keyword, the ```a``` argument is the area, not the diameter.  Rounded rectangles are similar, with the added radius for the corners: (solid colors only)  For polygons, specify the x and y coordinates as a series of numbers, with optional color and opacity.  Note that the coordinates may be either discrete:  or use substitution:  A combination of constants and substitution is also allowed.  For lines, specify the coordinates for the beginning ```(x1,y1)``` and end points ```(x2, y2)```. For horizontal and vertical lines specify the initial point and the length. Line thickness, color and opacity are optional, with defaults (0.2, gray, 100%).  A "pill" shape has is a horizontal line with rounded ends.  Curve is a quadratic Bezier curve: specify the beginning location ```(bx, by)```, the control point ```(cx, cy)```, and ending location ```(ex, ey)```.  For arcs, specify the location of the center point ```(x,y)```, the width and height, and the beginning and ending angles (in degrees). Line thickness, color and opacity are optional, with defaults (0.2, gray, 100%).  To make n-sided stars, use the "star" keyword: ```(x,y)``` is the center of the star, ```np``` is the number of points, and ```inner``` and ```outer``` are the sizes of the inner and outer points, respectively.  ## Arrows  Arrows with optional linewidth, width, height, color, and opacity. Default linewidth is 0.2, default arrow width and height is 3, default color and opacity is gray, 100%. The curve variants use the same syntax for specifying curves.  ## Braces  Left, right, up and down-facing braces. (x, y) is the location of the point of the brace, (aw, ah) are width and height of the braces's end curves; ```linewidth```, ```color``` and ```opacity``` are optional (defaults are 0.2, gray, 100%)  ## Brackets  Left, right, up and down-facing brackets. (x, y) is the location of the center of the bracket. For left and right-facing brackets, ```width``` is the size of the top and bottom portions, and ```height``` is the span of the bracket. For upward and downward-facing brackets, ```width``` is the span of of bracket, and ```height``` is the size of the left and right portions. ```linewidth```, ```color``` and ```opacity``` are optional (defaults are 0.2, gray, 100%)  ## Charts  Run the dchart(https://github.com/ajstarks/dchart/blob/master/README.md) command with the specified arguments.  ## Legend  Show a colored legend  Package decksh is a little language that generates deck markup code generation  Package decksh is a little language that generates deck markup loops  Package decksh is a little language that generates deck markup parsing
Keywords: dsl|golang|presentation|scripting|vector-graphics|visualization