1 | // This file is a part of the Framsticks GDK. |
---|
2 | // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. |
---|
3 | // Refer to http://www.framsticks.com/ for further information. |
---|
4 | |
---|
5 | #include "canvasutil.h" |
---|
6 | |
---|
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}; |
---|
11 | |
---|
12 | int* drawNeuroSymbol(CanvasDrawing* c,NeuroClass* cl,int x,int y,int w,int h) |
---|
13 | { |
---|
14 | int *data=std_unknown_symbol; |
---|
15 | if (cl) |
---|
16 | { |
---|
17 | data=cl->getSymbolGlyph(); |
---|
18 | if (!data) |
---|
19 | { |
---|
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; |
---|
25 | } |
---|
26 | } |
---|
27 | drawVector(c,data,x,y,w,h); |
---|
28 | return data; |
---|
29 | } |
---|
30 | |
---|
31 | void drawVector(CanvasDrawing* c,int data[],int x,int y,int w,int h) |
---|
32 | { |
---|
33 | if (!data) return; |
---|
34 | Pixel p; |
---|
35 | data++; |
---|
36 | for (int NL=*(data++);NL>0;NL--) |
---|
37 | { |
---|
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--) |
---|
43 | { |
---|
44 | p.x=x+(*(data++)*w)/100; |
---|
45 | p.y=y+(*(data++)*h)/100; |
---|
46 | c->lineTo(p); |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|