[286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
| 2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. |
---|
| 3 | // See LICENSE.txt for details. |
---|
[151] | 4 | |
---|
[147] | 5 | #include "canvasutil.h" |
---|
| 6 | |
---|
[789] | 7 | static int std_unknown_symbol[] = { 12, 1, 4, 25, 25, 75, 25, 75, 75, 25, 75, 25, 25 }; |
---|
| 8 | static int std_neuron_symbol[] = { 12, 1, 4, 75, 50, 25, 0, 25, 99, 75, 50, 100, 50 }; |
---|
| 9 | static int std_inputonly_symbol[] = { 14, 1, 5, 25, 40, 35, 40, 45, 50, 35, 60, 25, 60, 25, 40 }; |
---|
| 10 | static int std_outputonly_symbol[] = { 18, 1, 7, 75, 50, 75, 60, 55, 60, 65, 50, 55, 40, 75, 40, 75, 50, 100, 50 }; |
---|
[147] | 11 | |
---|
[789] | 12 | int* drawNeuroSymbol(CanvasDrawing* c, NeuroClass* cl, int x, int y, int w, int h) |
---|
[147] | 13 | { |
---|
[789] | 14 | int *data = std_unknown_symbol; |
---|
| 15 | if (cl) |
---|
[147] | 16 | { |
---|
[789] | 17 | data = cl->getSymbolGlyph(); |
---|
| 18 | if (!data) |
---|
[147] | 19 | { |
---|
[789] | 20 | if (cl->getPreferredInputs() == 0) |
---|
| 21 | data = std_outputonly_symbol; |
---|
| 22 | else if (cl->getPreferredOutput() == 0) |
---|
| 23 | data = std_inputonly_symbol; |
---|
| 24 | else data = std_neuron_symbol; |
---|
[147] | 25 | } |
---|
| 26 | } |
---|
[789] | 27 | drawVector(c, data, x, y, w, h); |
---|
| 28 | return data; |
---|
[147] | 29 | } |
---|
| 30 | |
---|
[789] | 31 | void drawVector(CanvasDrawing* c, int data[], int x, int y, int w, int h) |
---|
[147] | 32 | { |
---|
[789] | 33 | if (!data) return; |
---|
| 34 | Pixel p; |
---|
| 35 | data++; |
---|
| 36 | for (int NL = *(data++); NL > 0; NL--) |
---|
[147] | 37 | { |
---|
[789] | 38 | int NS = *(data++); |
---|
| 39 | p.x = x + (*(data++)*w) / 100; |
---|
| 40 | p.y = y + (*(data++)*h) / 100; |
---|
| 41 | c->moveTo(p); |
---|
| 42 | for (; NS > 0; NS--) |
---|
[147] | 43 | { |
---|
[789] | 44 | p.x = x + (*(data++)*w) / 100; |
---|
| 45 | p.y = y + (*(data++)*h) / 100; |
---|
| 46 | c->lineTo(p); |
---|
[147] | 47 | } |
---|
| 48 | } |
---|
| 49 | } |
---|