source: cpp/frams/canvas/nn_simple_layout.cpp @ 438

Last change on this file since 438 was 286, checked in by Maciej Komosinski, 10 years ago

Updated headers

  • Property svn:eol-style set to native
File size: 1018 bytes
RevLine 
[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.
[137]4
[135]5#include "nn_layout.h"
6#include "common/nonstd_math.h"
7#include <stdlib.h>
8
9static void randomlayout(NNLayoutState*);
10static void arraylayout(NNLayoutState*);
11
12extern void smartlayout(NNLayoutState*);
13
14struct NNLayoutFunction nn_layout_functions[] =
15{
16        { "Random", randomlayout, },
17        { "Dumb array", arraylayout, },
18        { "Smart", smartlayout, },
19        { 0, }
20};
21
22static void randomlayout(NNLayoutState*nn)
23{
24        int i;
25        int N = nn->GetElements();
26        for (i = 0; i < N; i++)
27        {
28                nn->SetXYWH(i, (int)rnd0N(300), (int)rnd0N(300), 50, 50);
29        }
30}
31
32static void arraylayout(NNLayoutState*nn)
33{
34        int e = 0, i, j;
35        int N = nn->GetElements();
36        int a = ((int)(sqrt(double(N)) - 0.0001)) + 1;
37        for (j = 0; j < a; j++)
38                for (i = 0; i < a; i++)
39                {
40                        if (e >= N) return;
41                        nn->SetXYWH(e, 70 * i + ((i + j) & 3) * 4, 70 * j + ((2 + i + j) & 3) * 4, 50, 50);
42                        e++;
43                }
44}
Note: See TracBrowser for help on using the repository browser.