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

Last change on this file since 1044 was 789, checked in by Maciej Komosinski, 6 years ago

Code formatting

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
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.
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{
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
31void 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}
Note: See TracBrowser for help on using the repository browser.