Giter Club home page Giter Club logo

celtic's Introduction

Celtic

This is a TikZ/PGF package for drawing Celtic knots. The basic idea is the same as my knots library: after drawing the full paths then they are redrawn in the vicinity of the crossings to get the over/under order correct.

The new feature of this package is the ability to generate a Celtic knot from a list of "walls" inside a rectangle. Given a rectangle together with a list of vertical and horizontal walls inside it, a Celtic knot can be generated wherein the paths travel diagonally bouncing off the walls and the edges of the rectangle. The crossings alternate.

The implementation works by carrying out the about algorithm. It picks a starting point and direction, and then procedes to trace out the path. If it comes back to its starting point, it stops and looks for another starting point. It continues this until all the available starting points are used up.

The path is actually built as a sequence of segments. Each segment starts and ends under another segment and consists of a single over crossing. The coordinate of the over-crossing is remembered so that the segment can be redrawn clipped to a neighbourhood of this crossing. As the drawings are so stylised, the shape of the clip region can be tightly controlled making it possible to use very thick paths.

The user interface to this implementation is via a single command \CelticDrawPath. It has a single mandatory argument which is a key/value list setting various parameters:

  • size={<width>,<height>}
  • width=<width>
  • height=<height> These set the size of the knot. The sizes should be even (strange things might happen if not).
  • crossings=<list>
  • symmetric crossings=<list>
  • ignore crossings=<list>
  • ignore symmetric crossings=<list> These specify a list of crossings to be considered. The first two set the crossings to be of a particular type. The second two mean that these crossings will not be considered as possible starting points for paths (this can be used to carve out a region). The crossings are specified as a semi-colon-delimited list. For the first two, the terms in the list have the format <x>,<y>,<type> where (x,y) is the coordinate of the crossing and <type> is one of | or - to designate the type of crossing. For ignoring, the terms are of the format <x>,<y>. Either <x> or <y> can be a range, specified as <x0>:<x1>. Because crossings lie only at certain points (x + y must be odd), the ranges actually step by 2.
  • flip changes the over/under order of crossings.
  • max steps because the algorithm is recursive, it has a built-in bailout. If the path does not return to its origin after max steps segments, the algorithm stops. This can lead to incomplete paths.
  • style=<style> is passed on to \tikzset.
  • at=<coord> is used to locate the lower left corner of the knot.
  • inner clip
  • outer clip These are used to set the size of the clipping region for the crossings. They are added to the line width to create a diamond region in which the crossing is redrawn. As the expectation is that the paths are drawn with the double option, there are two clips applied: one for each part of the path. This avoids artefacts being visible when anti-aliasing is in effect.

celtic's People

Contributors

loopspace avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.