Skip to content

Commit

Permalink
More work on igo diagram generation.
Browse files Browse the repository at this point in the history
Working towards: #5
  • Loading branch information
artasparks committed Oct 28, 2015
1 parent 123e869 commit da24545
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions src/diagrams/igo/igo.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,66 @@ gpub.diagrams.igo = {

var procMarks = {
BLACK: {
// XMARK->CIRCLE are arrays of pt strings
XMARK: [],
SQUARE: [],
TRIANGLE: [],
CIRCLE: []
CIRCLE: [],
// TEXTLABEL is an array of objects like {ptstr: str, label: str}
TEXTLABEL: []
},
WHITE: {
XMARK: [],
SQUARE: [],
TRIANGLE: [],
CIRCLE: []
CIRCLE: [],
TEXTLABEL: []
},
EMPTY: {
TEXTLABEL: []
}
};

// Glyphs are used in the context: \white|black[glyph]{intersection-pairs}
var markToGlyph = {
XMARK: '\\igocross',
SQUARE: '\\igosquare',
TRIANGLE: '\\igotriangle',
CIRCLE: '\\igocircle'
};

var number = /^\d+$/;
for (var ptstr in flattened.markMap()) {
var mark = flattened.markMap()[ptstr];
// Note: Igo does *not* support marks (except for text) on empty
// intersections, so we must makes user that there are intersections on
if (stoneMap[ptstr] &&
stoneMap[ptstr].color &&
mark != glift.flattened.symbols.TEXTLABEL) {
var stone = stoneMap[ptstr];
procMarks[stone.color][symbolStr(mark)] = toIgoCoord(toPt(ptstr));
seenPts[ptstr] = true;
} else if (mark != glift.flattened.symbols.TEXTLABEL) {
// Handle separately
if (stoneMap[ptstr] && stoneMap[ptstr].color) {
// Note: Igo does not support marks (except for number-labels) on
// empty intersections.
if (mark !== glift.flattened.symbols.TEXTLABEL) {
var stone = stoneMap[ptstr];
procMarks[stone.color][symbolStr(mark)] = toIgoCoord(toPt(ptstr));
seenPts[ptstr] = true;
} else if (mark === glift.flattened.symbols.TEXTLABEL &&
flattened.labelMap()[ptstr] &&
number.test(flattened.labelMap()[ptstr])) {
// Only number-labels are support on stones.
// TODO(kashomon): Since Igo supports special constructions for
// consecutive stones, this constructions hould be supported here
procMarks[stone.color][symbolStr(mark)] = {
ptstr: ptstr,
label: flattened.labelMap()[ptstr]
};
}
} else if (mark == glift.flattened.symbols.TEXTLABEL) {
// Arbitrary labels are supported for empty intersections.
proc[EMPTY][TEXTLABEL] = {
ptstr: ptstr,
label: flattened.labelMap()[ptstr]
};
}
// There are several opportunities for marks to not get caught here. Igo
// doesn't have support for:
// - Empty intersections with marks
// - Stones with labels other than numbers
}

for (var ptstr in flattened.stoneMap()) {
Expand Down

0 comments on commit da24545

Please sign in to comment.