Subversion Repositories AndroidProjects

Rev

Rev 1430 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1426 chris 1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
 
7
using BauzoidNET.graphics;
8
using BauzoidNET.math;
9
 
10
namespace BurutaruEditor.view
11
{
12
    public class Grid
13
    {
14
        public const float GRID_SIZE = 30;
15
        public static readonly Vector4 GRID_COLOR = new Vector4(0.3f, 0.4f, 0.3f, 1);
16
 
17
        private DocumentView mView = null;
18
 
19
        public Grid(DocumentView view)
20
        {
21
            mView = view;
22
        }
23
 
24
        public void Render(float posX, float posY)
25
        {
1448 chris 26
            posX *= mView.ZoomFactor;
27
            posY *= mView.ZoomFactor;
28
 
1426 chris 29
            posX += MainForm.App.getGraphics().getWidth() / 2;
30
            posY += MainForm.App.getGraphics().getHeight() / 2;
31
 
1448 chris 32
 
1430 chris 33
            float gridSize = GRID_SIZE * mView.ZoomFactor;
34
 
1426 chris 35
            // render grid
1430 chris 36
            float x = posX % (gridSize);
1426 chris 37
            while (x < MainForm.App.getGraphics().getWidth())
38
            {
39
                RenderUtil.drawLine(MainForm.App.getGraphics(), x, 0, x, MainForm.App.getGraphics().getHeight(), GRID_COLOR);
1430 chris 40
                x += gridSize;
1426 chris 41
            }
1430 chris 42
            float y = posY % (gridSize);
1426 chris 43
            while (y < MainForm.App.getGraphics().getHeight())
44
            {
45
                RenderUtil.drawLine(MainForm.App.getGraphics(), 0, y, MainForm.App.getGraphics().getWidth(), y, GRID_COLOR);
1430 chris 46
                y += gridSize;
1426 chris 47
            }
48
        }
49
    }
50
}