source: cpp/frams/canvas/canvasutil.cpp @ 176

Last change on this file since 176 was 151, checked in by sz, 11 years ago

(c) header added

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
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
7static int std_unknown_symbol[]={12, 1,4, 25,25, 75,25, 75,75, 25,75, 25,25};
8static int std_neuron_symbol[]={12, 1,4, 75,50, 25,0, 25,99, 75,50, 100,50};
9static int std_inputonly_symbol[]={14, 1,5, 25,40, 35,40, 45,50, 35,60, 25,60, 25,40};
10static int std_outputonly_symbol[]={18, 1,7, 75,50, 75,60, 55,60, 65,50, 55,40, 75,40, 75,50, 100,50};
11
12int* drawNeuroSymbol(CanvasDrawing* c,NeuroClass* cl,int x,int y,int w,int h)
13{
14int *data=std_unknown_symbol;
15if (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        }
27drawVector(c,data,x,y,w,h);
28return data;
29}
30
31void drawVector(CanvasDrawing* c,int data[],int x,int y,int w,int h)
32{
33if (!data) return;
34Pixel p;
35data++;
36for (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}
Note: See TracBrowser for help on using the repository browser.