{"id":13543311,"url":"https://github.com/ajstarks/deck","last_synced_at":"2025-04-06T19:13:26.041Z","repository":{"id":9376746,"uuid":"11234770","full_name":"ajstarks/deck","owner":"ajstarks","description":"A Go Package for generation of slide decks and information displays","archived":false,"fork":false,"pushed_at":"2025-01-18T15:03:28.000Z","size":677956,"stargazers_count":301,"open_issues_count":1,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-06T07:38:12.853Z","etag":null,"topics":["deck","go","golang","golang-library","markup","pdf","png","presentations","slide-deck","svg","xml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajstarks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-07-07T14:47:52.000Z","updated_at":"2025-03-14T21:54:35.000Z","dependencies_parsed_at":"2024-10-26T00:28:02.539Z","dependency_job_id":null,"html_url":"https://github.com/ajstarks/deck","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajstarks%2Fdeck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajstarks%2Fdeck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajstarks%2Fdeck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajstarks%2Fdeck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajstarks","download_url":"https://codeload.github.com/ajstarks/deck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247535520,"owners_count":20954576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deck","go","golang","golang-library","markup","pdf","png","presentations","slide-deck","svg","xml"],"created_at":"2024-08-01T11:00:29.400Z","updated_at":"2025-04-06T19:13:26.024Z","avatar_url":"https://github.com/ajstarks.png","language":"Go","readme":"# deck: A Go package for slide decks\n\n[![Deck Intro][2]][1]\n\n[1]: http://www.flickr.com/photos/ajstarks/9592115613/ \"Deck Intro by ajstarks, on Flickr\"\n[2]: https://farm4.staticflickr.com/3820/13415195635_64da6a7a90.jpg \n\nDeck is a library for clients to make scalable presentations, using a standard markup language.\nClients read deck files into the Deck structure, and traverse the structure for display, publication, etc.\nClients may be interactive or produce standard formats such as SVG or PDF.\n\nAlso included is a REST API for listing content, uploading, stopping, starting and removing decks, \ngenerating tables, and playing video.\n\nThe [deck on Deck](http://speakerdeck.com/ajstarks/deck-a-go-package-for-presentations)\n\n## Elements ##\n\n* deck: enclosing element \n* canvas: describe the dimensions of the drawing canvas, one per deck\n* metadata elements: title, creator, publisher, subject, description, date\n* slide: within a deck, any number of slides, specify the slide duration, background and text colors.\n\nwithin slides any number of:\n\n* text: plain, textblock, or code\n* list: plain, bullet, number, centered\n* image: JPEG or PNG images\n* line: straight line\n* rect: rectangle\n* ellipse: ellipse\n* curve: quadraticd Bezier curve\n* arc: elliptical arc\n* polygon: filled polygon\n* polyline: closed polyline\n\n## Markup ##\n\nHere is a sample deck in XML:\n\n```html\n\u003cdeck\u003e\n\t\u003ctitle\u003eSample Deck\u003c/title\u003e\n\t\u003ccanvas width=\"1024\" height=\"768\"/\u003e\n\t\u003cslide bg=\"maroon\" fg=\"white\" duration=\"1s\"\u003e\n\t\t\u003cimage xp=\"20\" yp=\"30\" width=\"256\" height=\"256\" name=\"picture.png\"/\u003e\n\t\t\u003ctext xp=\"20\" yp=\"80\" sp=\"3\" link=\"http://example.com/\"\u003eDeck uses these elements\u003c/text\u003e\n\t\t\u003cline xp1=\"20\" yp1=\"75\" xp2=\"90\" yp2=\"75\" sp=\"0.3\" color=\"rgb(127,127,127)\"/\u003e\n\t\t\u003clist xp=\"20\" yp=\"70\" sp=\"1.5\"\u003e\n\t\t\t\u003cli\u003ecanvas\u003c/li\u003e\n\t\t\t\u003cli\u003eslide\u003c/li\u003e\n\t\t\t\u003cli\u003etext\u003c/li\u003e\n\t\t\t\u003cli\u003elist\u003c/li\u003e\n\t\t\t\u003cli\u003eimage\u003c/li\u003e\n\t\t\t\u003cli\u003eline\u003c/li\u003e\n\t\t\t\u003cli\u003erect\u003c/li\u003e\n\t\t\t\u003cli\u003eellipse\u003c/li\u003e\n\t\t\t\u003cli\u003ecurve\u003c/li\u003e\n\t\t\t\u003cli\u003earc\u003c/li\u003e\n\t\t\u003c/list\u003e\n\t\t\u003cline    xp1=\"20\" yp1=\"10\" xp2=\"30\" yp2=\"10\"/\u003e\n\t\t\u003crect    xp=\"35\"  yp=\"10\" wp=\"4\" hp=\"3\" color=\"rgb(127,0,0)\"/\u003e\n\t\t\u003cellipse xp=\"45\"  yp=\"10\" wp=\"4\" hp=\"3\" color=\"rgb(0,127,0)\"/\u003e\n\t\t\u003ccurve   xp1=\"60\" yp1=\"10\" xp2=\"75\" yp2=\"20\" xp3=\"70\" yp3=\"10\" /\u003e       \n\t\t\u003carc     xp=\"55\"  yp=\"10\" wp=\"4\" hp=\"3\" a1=\"0\" a2=\"180\" color=\"rgb(0,0,127)\"/\u003e\n\t\t\u003cpolygon xc=\"75 75 80\" yc=\"8 12 10\" color=\"rgb(0,0,127)\"/\u003e\n\t\u003c/slide\u003e\n\u003c/deck\u003e\n```\n\n\nThe list and text elements have common attributes:\n\n```\nxp: horizontal percentage\nyp: vertical percentage\nsp: font size percentage\nlp: line spacing percentage\ntype: \"bullet\", \"number\" (list), \"block\", \"code\" (text)\nalign: \"left\", \"middle\", \"end\"\ncolor: SVG names (\"maroon\"), RGB \"rgb(127,0,0)\" or hex (\"#rrggbb\")\nfont: \"sans\", \"serif\", \"mono\"\nopacity: opacity percentage\nrotation: (0-360 degrees)\nlink: url\n```\n\nSee the example directory for example decks.\n\n## Layout ##\n\nAll layout in done in terms of percentages, using a coordinate system with the origin (0%, 0%) at the lower left.\nThe x (horizontal) direction increases to the right, with the y (vertical) direction increasing to upwards.\nFor example, to place an element in the middle of the canvas, specify xp=\"50\" yp=\"50\". To place an element\none-third from the top, and one-third from the bottom: xp=\"66.6\" yp=\"33.3\".\n\nThe size of text is also scaled to the width of the canvas. For example sp=\"3\" is a typical size for slide headings.\nThe dimensions of graphical elements (width, height, stroke width) are also scaled to the canvas width.\n\nThe content of the slides are automatically scaled based on the specified canvas size \n(sane defaults are should be set the clients, if dimensions not specified)\n\n[![deck's percent grid][4]][3]\n\n[![Deck's percentage based layout][6]][5]\n\n[3]: http://www.flickr.com/photos/ajstarks/9469642769/\n[4]: http://farm8.staticflickr.com/7449/9469642769_c2dc83afac.jpg \"deck's percent grid by ajstarks, on Flickr\"\n\n[5]: http://www.flickr.com/photos/ajstarks/9409916329/\n[6]: http://farm4.staticflickr.com/3818/9409916329_6b8e134f16.jpg \"Deck's percentage based layout by ajstarks, on Flickr\"\n\n## Clients ##\n\n### example client ###\n\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/ajstarks/deck\"\n)\n\nfunc dotext(x, y, size float64, text deck.Text) {\n\tfmt.Println(\"\\tText:\", x, y, size, text.Tdata)\n}\n\nfunc dolist(x, y, size float64, list deck.List) {\n\tfmt.Println(\"\\tList:\", x, y, size)\n\tfor i, l := range list.Li {\n\t\tfmt.Println(\"\\t\\titem\", i, l)\n\t}\n}\nfunc main() {\n\tpresentation, err := deck.Read(\"deck.xml\", 1024, 768) // open the deck\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfor slidenumber, slide := range presentation.Slide { // for every slide...\n\t\tfmt.Println(\"Processing slide\", slidenumber)\n\t\tfor _, t := range slide.Text { // process the text elements\n\t\t\tx, y, size := deck.Dimen(presentation.Canvas, t.Xp, t.Yp, t.Sp)\n\t\t\tdotext(x, y, size, t)\n\t\t}\n\t\tfor _, l := range slide.List { // process the list elements\n\t\t\tx, y, size := deck.Dimen(presentation.Canvas, l.Xp, l.Yp, l.Sp)\n\t\t\tdolist(x, y, size, l)\n\t\t}\n\t}\n}\n```\n\nCurrently there are four clients: pdfdeck, pngdeck, svgdeck and vgdeck.\n\n\nFor PDF decks, install pdfdeck:\n\n```sh\ngo install github.com/ajstarks/deck/cmd/pdfdeck@latest\n```\n\npdfdeck produces decks in PDF corresponding to the input file:\n\n```sh\npdfdeck deck.xml\n```\n\nproduces deck.pdf\n\nFor SVG decks, install svgdeck:\n\n```sh\ngo install github.com/ajstarks/deck/cmd/svgdeck@latest\n```\n\nThis command:\n\n```sh\nsvgdeck deck.xml\n```\n\nproduces one slide per SVG file, with each slide linked to the next.\n\nFor png decks, install pngdeck:\n\n```sh\ngo install github.com/ajstarks/deck/cmd/pngdeck@latest\n```\n\nThis command:\n\n```sh\npngdeck deck.xml\n```\n\nmakes one image per slide, numbered like deck-00001.png\n\nvgdeck is a program for showing presentations on the Raspberry Pi, using the openvg library.\nTo install:\n\n```sh\ngo get github.com/ajstarks/deck/cmd/vgdeck\n```\n\nTo run vgdeck, specify one or more files (marked up in deck XML) on the command line, and each will be shown in turn.\n\n```sh\nvgdeck sales.xml program.xml architecture.xml\n```\n\nHere are the vgdeck commands:\n\n*  Next slide: +, Ctrl-N, [Return]\n*  Previous slide, -, Ctrl-P, [Backspace]\n*  First slide: ^, Ctrl-A\n*  Last slide: $, Ctrl-E\n*  Reload: r, Ctrl-R\n*  X-Ray: x, Ctrl-X\n*  Search: /, Ctrl-F\n*  Save: s, Ctrl-S\n*  Quit: q\n\nAll commands are a single keystroke, acted on immediately\n(only the search command waits until you hit [Return] after entering your search text)\nTo cycle through the deck, repeatedly tap [Return] key\n\n### DECKFONTS\n\npdfdeck and pngdeck use the DECKFONTS environment variable as the location of font files. Choose a directory for your fonts, say $HOME/deckfonts, and set the DECKFONTS environment variable to this directory. Note that the repository at github.com/ajstarks/deckfonts contains a set of fonts (Times, Helvetica, Courier, Zapf Dingbats, Charter, Fira, Go, IBM Plex, and Noto) for you to use:\n\n```\nexport DECKFONTS=$HOME/deckfonts\ncd $HOME\ngit clone https://github.com/ajstarks/deckfonts\n...\npdfdeck foo.xml # (use helvetica as the default)\npdfdeck -sans NotoSans-Regular -serif NotoSerif-Regular -mono NotoMono-Regular foo.xml # specify fonts\n```\n\n\nAlternatively you can manually install fonts from the gofpdf package: (these instructions assume you installed gofpdf in your GOPATH.)\n\n```sh\nmkdir $HOME/deckfonts # make the DECKFONTS directory\nexport DECKFONTS=$HOME/deckfonts # you should make this permanent in your shell startup\ncp $GOPATH/src/github.com/jung-kurt/gofpdf/font/*.json $DECKFONTS\n\n```\nIn general you can place TrueType files obtained from anywhere in your DECKFONTS directory and then you can use them with pdfdeck:  For example, the gofpdf package has DejaVu fonts:\n\n```\ncp $GOPATH/src/github.com/jung-kurt/gofpdf/font/DejaVu*.ttf $DECKFONTS\npdfdeck -sans DejaVuSansCondensed foo.xml\n```\n\nAlso, to use the Go fonts:\n\n```sh\ncd $HOME\nmkdir gofonts\ncd gofonts\ngit clone https://go.googlesource.com/image\ncp image/font/gofont/ttfs/*.ttf $DECKFONTS\n...\npdfdeck -sans Go-Regular -mono Go-Mono foo.xml\n```\n\nyou can also manually set the font directory via command line option:\n\n```sh\npdfdeck -fontdir $GOPATH/src/github.com/jung-kurt/gofpdf/font foo.xml\n```\n\n\n## API ##\n\nThe command `deckd` is a server program that provides an API for slide decks. \nThe API supports deck start, stop, listing, upload, and remove. Responses are encoded in JSON.\n\nTo install:\n        \n```sh\ngo get github.com/ajstarks/deck/cmd/deckd\n```\n\nCommand line options control the working directory and address:port\n\n-port Address:port (default: localhost:1958) \n\n-dir [name] working directory (default: \".\")\n\n-maxupload [bytes] upload limit\n\nGET / lists the API\n\nGET /deck lists information on content, (filename, metadata (number of slides or image dimensions), modification time) in JSON\n\nGET /deck?filter=[type] filter content list by type (std, deck, image, video)\n\nPOST /deck/file.xml?cmd=[duration]  starts up a deck; the deck, duration, and process id are returned in JSON\n\nPOST /deck/file.xml?slide=[number]  start at the specified slide\n\nPOST /deck?cmd=stop stops the running deck\n\nDELETE /deck/file.xml  removes a deck\n\nPUT or POST to /upload  uploads the contents of the Deck: header to the server\n\nPOST /table with the content of a tab-separated list, creates a slide with a formatted table, the Deck: header specifies the resulting deck file\n\nPOST /table/?textsize=[size] -- specify the text size of the generated table\n\nPOST /media plays the media file specified in the Media: header\n\nThe command `deck` is a command line interface to the deck Web API. Install it like this:\n\n```bash\ngo get github.com/ajstarks/deck/cmd/deck\n\n$ deck\nUsage:\n\tList:    deck list [image|deck|video]\n\tPlay:    deck play file [duration] [start-slide]\n\tStop:    deck stop\n\tUpload:  deck upload files...\n\tRemove:  deck remove files...\n\tVideo:   deck video file\n\tTable:   deck table file [textsize]\n```\n\nThe shell script version of the command is in `deck.sh`. This version uses `gttp` (go get github.com/dgryski/gttp) to make HTTP requests.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajstarks%2Fdeck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajstarks%2Fdeck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajstarks%2Fdeck/lists"}