338 | | P = polygon(coords, color=self.color()) |
339 | | P += polygon(coords, fill=False, color=border_color, thickness=border_thickness) |
340 | | return P |
| 338 | if style == 'fill': |
| 339 | P = polygon(coords, color=self.color()) |
| 340 | P += polygon(coords, fill=False, color=border_color, thickness=border_thickness) |
| 341 | return P |
| 342 | elif style == 'edges': |
| 343 | if isinstance(self, DeltaPiece): |
| 344 | edges = ('north_west', 'south', 'north_east') |
| 345 | elif isinstance(self, NablaPiece): |
| 346 | edges = ('south_west', 'north', 'south_east') |
| 347 | else: |
| 348 | edges = self.edges() |
| 349 | P = Graphics() |
| 350 | for (i, edge) in enumerate(edges): |
| 351 | P += line([coords[i], coords[(i+1)%3]], color=self.edge_color(edge), thickness=border_thickness) |
| 352 | return P |
| 353 | else: |
| 354 | return NotImplemented |
| 355 | |
| 356 | def edge_color(self, edge): |
| 357 | """ |
| 358 | Color of the specified edge of ``self`` (to be used when plotting the |
| 359 | piece). |
| 360 | |
| 361 | EXAMPLES:: |
| 362 | |
| 363 | sage: from sage.combinat.knutson_tao_puzzles import DeltaPiece |
| 364 | sage: delta = DeltaPiece('1','0','10') |
| 365 | sage: delta.edge_color('south') |
| 366 | 'blue' |
| 367 | sage: delta.edge_color('north_west') |
| 368 | 'red' |
| 369 | sage: delta.edge_color('north_east') |
| 370 | (1, 0.65, 0) |
| 371 | """ |
| 372 | edge_label = self.edge_label(edge) |
| 373 | colors = {'1': 'blue', '0': 'red'} |
| 374 | if edge_label in colors: |
| 375 | color = colors[edge_label] |
| 376 | elif 'K' in edge_label: |
| 377 | color = 'orange' |
| 378 | elif edge_label.startswith('T'): |
| 379 | color = 'yellow' |
| 380 | else: |
| 381 | color = 'white' |
| 382 | return color |
1419 | | # FIXME: I don't think this method survived the refactoring |
1420 | | def _plot_color_edges(self, labels=True): |
1421 | | P = Graphics() |
1422 | | text_color = (0, 0, 0) |
1423 | | colors = {10: (1, 0.65, 0), 1: 'blue', 0: 'red'} |
1424 | | line_thickness = 3 |
1425 | | coords = [(k, -d) for d in range(self._n) for k in range(-d, d + 1, 2)] |
1426 | | for ((k, d), piece) in zip(coords, self): |
1427 | | if isinstance(piece, RhombusPiece): |
1428 | | triangle = piece.north_piece() |
1429 | | P += line([(k, d), (k - 1, d - 1)], color=colors[triangle['north_west']], thickness=line_thickness) |
1430 | | P += line([(k - 1, d - 1), (k + 1, d - 1)], color=colors[triangle['south']], thickness=line_thickness) |
1431 | | P += line([(k + 1, d - 1), (k, d)], color=colors[triangle['north_east']], thickness=line_thickness) |
1432 | | |
1433 | | triangle = piece.south_piece() |
1434 | | P += line([(k, d - 2), (k - 1, d - 1)], color=colors[triangle['south_west']], thickness=line_thickness) |
1435 | | P += line([(k - 1, d - 1), (k + 1, d - 1)], color=colors[triangle['north']], thickness=line_thickness) |
1436 | | P += line([(k + 1, d - 1), (k, d - 2)], color=colors[triangle['south_east']], thickness=line_thickness) |
1437 | | |
1438 | | if labels: |
1439 | | P += text("%s" % piece['north_west'], (k - 0.5, d - 0.5), color=text_color, rotation=60) |
1440 | | P += text("%s" % piece['north_east'], (k + 0.5, d - 0.5), color=text_color, rotation=-60) |
1441 | | P += text("%s" % piece.north_piece()['south'], (k, d - 1), color=text_color) |
1442 | | else: |
1443 | | P += line([(k, d), (k - 1, d - 1)], color=colors[piece['north_west']], thickness=line_thickness) |
1444 | | P += line([(k - 1, d - 1), (k + 1, d - 1)], color=colors[piece['south']], thickness=line_thickness) |
1445 | | P += line([(k + 1, d - 1), (k, d)], color=colors[piece['north_east']], thickness=line_thickness) |
1446 | | if labels: |
1447 | | P += text("%s" % piece['north_west'], (k - 0.5, d - 0.5), color=text_color, rotation=60) |
1448 | | P += text("%s" % piece['north_east'], (k + 0.5, d - 0.5), color=text_color, rotation=-60) |
1449 | | P += text("%s" % piece['south'], (k, d - 1), color=text_color) |
1450 | | |
1451 | | P.set_aspect_ratio(1.73) |
1452 | | P.axes(False) |
1453 | | return P |
1454 | | |