{"id":28146849,"url":"https://github.com/susam/cfrs","last_synced_at":"2026-01-24T14:45:51.262Z","repository":{"id":201081634,"uuid":"706889419","full_name":"susam/cfrs","owner":"susam","description":"An extremely minimal drawing language consisting of only 6 simple commands: C, F, R, S, [, and ].","archived":false,"fork":false,"pushed_at":"2025-12-26T00:05:10.000Z","size":107,"stargazers_count":261,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T05:46:05.323Z","etag":null,"topics":["animation","graphics","html5-canvas","turtle","turtle-graphics"],"latest_commit_sha":null,"homepage":"https://susam.net/cfrs.html","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/susam.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-18T20:17:18.000Z","updated_at":"2025-12-26T00:05:13.000Z","dependencies_parsed_at":"2025-05-14T23:14:50.641Z","dependency_job_id":"d79e6853-2fbc-46e9-834b-b665b130ec85","html_url":"https://github.com/susam/cfrs","commit_stats":null,"previous_names":["susam/cfr","susam/cfrs"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/susam/cfrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Fcfrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Fcfrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Fcfrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Fcfrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/susam","download_url":"https://codeload.github.com/susam/cfrs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Fcfrs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28730193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["animation","graphics","html5-canvas","turtle","turtle-graphics"],"created_at":"2025-05-14T23:14:44.969Z","updated_at":"2026-01-24T14:45:51.247Z","avatar_url":"https://github.com/susam.png","language":"HTML","readme":"CFRS[]\n======\n\nCFRS[] (CFRS Brackets) is an extremely minimal drawing language that\nconsists of only six simple commands:\n\n- `C`: Change colour.\n- `F`: Move forward by one cell and paint the new cell.\n- `R`: Rotate right (clockwise) by 45°.\n- `S`: Sleep for 20 ms.\n- `[`: Begin a repeatable block and continue executing subsequent code.\n- `]`: Repeat the current block and exit the block.\n\nNote that `]` goes back to the beginning of the current repeatable\nblock, executes it again and exits the block.  Thus a block bounded by\n`[` and `]` behaves like a loop that runs twice before the block\nexits.  See sections [Commands](#commands) and [Loops](#loops) for\nmore details about this.\n\n[![Screenshot of CFRS Brackets Colour Bars][IMG0]][DEMO0]\n\n**[See Demo][DEMO0]**\n\n**[Draw Now][DRAW1]**\n\n\nContents\n--------\n\n* [Introduction](#introduction)\n* [Implementation](#implementation)\n* [Get Started](#get-started)\n* [Demos](#demos)\n  * [Built-In Demos](#built-in-demos)\n  * [Community Demos](#community-demos)\n* [Canvas](#canvas)\n* [Turtle](#turtle)\n* [Commands](#commands)\n* [Loops](#loops)\n* [Code Normalisation and Validation](#code-normalisation-and-validation)\n* [Distributable Links](#distributable-links)\n* [Licence](#licence)\n* [Support](#support)\n* [See Also](#see-also)\n\n\nIntroduction\n------------\n\nCFRS[] is inspired by the educational programming language Logo and\nthe esoteric programming language P′′ (P double prime).  Inspired by\nLogo, CFRS[] has a virtual turtle that moves around on a graphical\ncanvas and paints the canvas as it moves.  Inspired by P′′, it has an\nextremely small set of commands.  CFRS[] is intentionally meant to be\nhard to write in and hard to read.\n\nThis project introduces the CFRS[] language and provides a web-based\nimplementation using HTML5 Canvas and JavaScript.\n\n\nImplementation\n--------------\n\nThe current stable version of a CFRS[] implementation is available at\nthe following links:\n\n* [susam.net/cfrs.html][DRAW1]\n* [susam.github.io/cfrs.html][DRAW2]\n\n[DRAW1]: https://susam.net/cfrs.html\n[DRAW2]: https://susam.github.io/cfrs.html\n[DRAW3]: https://susam.github.io/cfrs/cfrs.html\n\n[DEMO0]: https://susam.net/cfrs.html#0\n[DEMO3]: https://susam.net/cfrs.html#3\n\n[IMG0]: https://susam.github.io/blob/img/cfrs/cfrs-0.1.0-bars.png\n[IMG3]: https://susam.github.io/blob/img/cfrs/cfrs-0.1.0-rings.png\n\n\nGet Started\n-----------\n\nEnter the following code in the input field to draw a vertical column\nconsisting of 16 cells:\n\n```\nFFFFFFFFFFFFFFFF\n```\n\nHowever, using the block commands, this can be shortened to the\nfollowing code:\n\n```\n[[[FF]]]\n```\n\nThe following code draws a vertical column of 64 cells:\n\n```\n[[[[[FF]]]]]\n```\n\nThe following code draws a vertical column of 64 cells *gradually*.\nThe `S` command causes the execution to sleep for 20 ms in each\niteration of the innermost block.\n\n```\n[[[[[FFS]]]]]\n```\n\nThe maximum code length supported is 256 bytes.\n\n\nDemos\n-----\n\n### Built-In Demos\n\nThe implementation in this project comes with a small collection of\ndemos.  Type any digit between `0` and `5` to see the corresponding\ndemo.  Typing a digit may require an external keyboard.  If there is\nno external keyboard available, append `#` and a digit to the page URL\nwith an on-screen keyboard.  For example, the URL\n\u003chttps://susam.net/cfrs.html#3\u003e shows demo number 3.\n\n[![Screenshot of CFRS Brackets Demo 3][IMG3]][DEMO3]\n\nHere are direct links to demos currently available:\n[#0](https://susam.net/cfrs.html#0),\n[#1](https://susam.net/cfrs.html#1),\n[#2](https://susam.net/cfrs.html#2),\n[#3](https://susam.net/cfrs.html#3),\n[#4](https://susam.net/cfrs.html#4),\n[#5](https://susam.net/cfrs.html#5).\n\n\n### Community Demos\n\nA few community members have created several interesting and\nimpressive demos.  These demos can be found at [demo.html][].\n\nIf you have an interesting demo that fits in 64 bytes of code, please\n[create an issue][ISSUES] and share it.  If the demo looks very\ninteresting, it may be added to [demo.html][].\n\n[demo.html]: https://susam.github.io/cfrs/demo.html\n\n\nCanvas\n------\n\nThe drawing canvas is divided into a grid of 256x256 cells.  There are\n256 rows with 256 cells in each row.  Initially, all 65536 cells of\nthe canvas are painted black.\n\nThe rows are numbered 0, 1, 2, etc.  Similarly, the columns are\nnumbered 0, 1, 2, etc. too.  The cell at the top-left corner is at row\n0 and column 0.  The cell at the bottom-right corner is at row 255 and\ncolumn 255.\n\n\nTurtle\n------\n\nThe CFRS[] commands are described in terms of the movement of an\ninvisible virtual turtle and changes in its properties.  The turtle\nhas three properties:\n\n- Location: The cell where the turtle is currently situated.\n- Heading: The direction for the turtle's next movement if it moves.\n- Colour: The colour to be used for painting the next cell.\n\nIts current location, heading and colour are determined by its initial\nproperties and the preceding commands.  The initial properties of the\nturtle are as follows:\n\n- Location: Row 127 and column 127.\n- Heading: North (up).\n- Colour: White.\n\n\nCommands\n--------\n\nThis section describes all five commands of CFRS[] in detail.\n\n\n### C\n\nThe `C` command changes the colour used to paint the next cell.  A\ntotal of 8 colours are supported.  They are:\n\n- Black\n- Blue\n- Green\n- Cyan\n- Red\n- Magenta\n- Yellow\n- White\n\nThe initial colour is white.  Each `C` command changes the drawing\ncolour to the next one in the above list.  When the current drawing\ncolour is white, `C` changes the drawing colour to black, i.e. the\ndrawing colour *wraps around* to black.\n\nThe following code draws four cells in white (the initial colour),\nthen four cells in black and finally four cells in blue.\n\n```\nFFFFCFFFFCFFFF\n```\n\nThe first `C` in the code above changes the drawing colour from white\nto black.  The second `C` changes it from black to blue.  Note that\nthe canvas background is black in colour, so the four cells drawn in\nblack are going to be invisible on the black background.\n\n\n### F\n\nThe `F` command moves the virtual turtle forward by one cell and\npaints the cell it moves to with the current drawing colour.  The\ndirection of movement is determined by the current heading of the\nturtle.  Each `F` command moves the turtle by exactly one cell and\npaints the entire cell it has moved to.  This is true for diagonal\nmovements too.  For example, if the turtle moves in the northeast\ndirection, it moves from the current cell diagonally to the next cell\nthat is touching the top-right corner of the current cell.  It then\npaints that new cell it has moved to.\n\nWhen the turtle is at the edge of the canvas and the next command\nmoves the turtle beyond the edge, the turtle simply wraps around to\nthe opposite edge of the canvas, i.e. the turtle reenters the canvas\nfrom the opposite edge.\n\n\n### R\n\nThe `R` command changes the heading of the turtle by rotating it by\n1/8th of a complete turn.  The initial heading is north (up).  The\nfollowing command rotates the turtle three times so that its heading\nchanges to southeast and then paints 4 cells diagonally:\n\n```\nRRRFFFF\n```\n\n\n### S\n\nThe `S` command makes the turtle sleep for 20 ms.  When the evaluator\nencounters `S`, it pauses for 20 ms before resuming with the\nevaluation of the remainder of the code.\n\n\n### [\n\nThe `[` command marks the beginning of a repeatable block.  It does\nnot change the properties of the turtle.  This is a control flow\ncommand that only introduces a new repeatable block without producing\nany visual side effects.  Execution of the remaining code that comes\nafter `[` continues as usual.\n\n\n### ]\n\nThe `]` command marks the end of a repeatable block.  When the\nevaluator reads `]`, it jumps back to the beginning of the current\nrepeatable block, executes it again and exits the block.  As a result,\nwhen the code evaluator enters a block marked with `[`, the block is\nexecuted twice before the evaluator leaves the end of the block marked\nwith `]`.\n\n\nLoops\n-----\n\nThe following code moves the turtle twice and then rotates it once:\n\n```\n[F]R\n```\n\nThe opening square bracket (`[`) marks the beginning of a block.  Then\n`F` is executed as usual thereby moving the turtle forward once.  Then\nthe closing square bracket (`]`) repeats the current block thereby\nexecuting the `F` inside the block again.  Finally the evaluator moves\nahead to `R` and rotates the turtle once.  Note that the evaluator\nleaves a block after the block has been executed twice.\n\nThe following code moves the turtle 6 times:\n\n```\n[FFF]\n```\n\nThe inner block executes `FFF` twice.  The outer block repeats the\ninner block twice.  As a result, the inner block is repeated four\ntimes and the turtle moves forward by 12 cells.\n\nThe following command moves the turtle 64 times *gradually*.  The\nturtle sleeps for 20 ms after each movement.\n\n```\n[[[[[[FS]]]]]]\n```\n\n\nCode Normalisation and Validation\n---------------------------------\n\nThe reference implementation performs the following two normalisation\nsteps (in the given order) on the input code before executing the\ncode:\n\n- Lowercase letters are converted to uppercase.\n- Any character in the input code that does not match a valid CFRS[]\n  command is removed.\n\nThe reference implementation generates errors when the following conditions are met:\n\n- A closing square bracket (`]`) is encountered that does not have a\n  corresponding open square bracket (`[`).\n- The length of the code exceeds 256 characters.\n\nWhen an error is generated, the entire canvas is painted red and the\nexecution halts immediately.\n\n\nDistributable Links\n-------------------\n\nThe reference implementation provides distributable links when the\ninput code is 64 bytes or less in length.  Note that the\nimplementation allows code up to a maximum length of 256 bytes.\nHowever, no distributable link is generated when the code length\nexceeds 64 bytes.  Thus code that does not exceed 64 bytes in length\nhas a special status in the reference implementation.\n\nThe distributable link encodes the input code and appends it as a URL\nfragment to the address of the current page.  Copy the URL with the\nencoded input code embedded in it from the address bar of the web\nbrowser in order to share it with others.  When the recipient of the\nURL opens it with their web browser, the implementation reads the code\nembedded in the URL, expands it and executes it.\n\n\nLicence\n-------\n\nThis is free and open source software.  You can use, copy, modify,\nmerge, publish, distribute, sublicence and/or sell copies of it, under\nthe terms of the MIT Licence.  See [LICENSE.md][L] for details.\n\nThis software is provided \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nexpress or implied.  See [LICENSE.md][L] for details.\n\n[L]: LICENSE.md\n\n\nSupport\n-------\n\nTo report bugs or ask questions, [create issues][ISSUES].\n\n[ISSUES]: https://github.com/susam/cfrs/issues\n\n\nSee Also\n--------\n\nSee [Andromeda Invaders](https://github.com/susam/invaders), a\n1980s-arcade-style game written using HTML5, Canvas and Web Audio.\n\nSee [FXYT](https://github.com/susam/fxyt), a tiny canvas colouring\nlanguage with stack-based commands.\n\nSee [PC Face](https://github.com/susam/pcface), a collection of bitmap\narrays for rendering CP437 glyphs using IBM PC OEM fonts.\n\n\u003c!--\nRelease Checklist\n-----------------\n\n- Update version in HTML (1 place).\n- Update copyright in HTML (1 place).\n- Update copyright in LICENSE.md.\n- Disable logging.\n- Update CHANGES.md.\n- Run the following commands:\n\n  npm run lint\n  git status\n  git add -p\n\n  VER=\u003cVER\u003e\n  git commit -em \"Set version to $VER\"\n  git tag $VER -m \"CFRS[] $VER\"\n  git push origin main $VER\n\n  git remote add cb https://codeberg.org/susam/cfrs.git\n  git push cb --all\n  git push cb --tags\n  git push cb main:pages\n--\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusam%2Fcfrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsusam%2Fcfrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusam%2Fcfrs/lists"}