Skip to content

Instantly share code, notes, and snippets.

@mnemnion
Created March 27, 2010 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnemnion/346422 to your computer and use it in GitHub Desktop.
Save mnemnion/346422 to your computer and use it in GitHub Desktop.
Asymptote code that renders a Goban
// now a function, also, can draw to any picture not just currentpicture
void drawgoban(picture pic=currentpicture, int gobansize, int gobanlines=19) {
int gobancounter=gobanlines + 1;
unitsize(pic,gobansize/(gobancounter+1));
//Bounding Box and background
filldraw(pic,box((0,0),(gobancounter,gobancounter)),white,white);
//Draw grid
for(int i=1; i < gobancounter; ++i) {
draw(pic,(i,1)--(i,gobanlines));
}
for(int i=1; i < gobancounter; ++i) {
draw(pic,(1,i)--(gobanlines,i));
}
//Hoshi!
if(gobanlines > 5) {
if (gobansize<70) { // muck about with this until the hoshi look right
dotfactor = 4;
}
dot(pic,(4,4));
dot(pic,(gobancounter-4,4));
dot(pic,(gobancounter-4,gobancounter-4));
dot(pic,(4,gobancounter-4));
dotfactor = 6; // hard coded, should restore to default, fix later
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment