Rev 1430 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BauzoidNET.graphics;
using BauzoidNET.math;
namespace BurutaruEditor
.view
{
public class Grid
{
public const float GRID_SIZE
= 30;
public static readonly Vector4 GRID_COLOR
= new Vector4
(0
.3f, 0
.4f, 0
.3f,
1);
private DocumentView mView
= null;
public Grid
(DocumentView view
)
{
mView
= view
;
}
public void Render
(float posX,
float posY
)
{
posX
*= mView
.ZoomFactor;
posY
*= mView
.ZoomFactor;
posX
+= MainForm
.App.getGraphics().getWidth() / 2;
posY
+= MainForm
.App.getGraphics().getHeight() / 2;
float gridSize
= GRID_SIZE
* mView
.ZoomFactor;
// render grid
float x
= posX
% (gridSize
);
while (x
< MainForm
.App.getGraphics().getWidth())
{
RenderUtil
.drawLine(MainForm
.App.getGraphics(), x,
0, x, MainForm
.App.getGraphics().getHeight(), GRID_COLOR
);
x
+= gridSize
;
}
float y
= posY
% (gridSize
);
while (y
< MainForm
.App.getGraphics().getHeight())
{
RenderUtil
.drawLine(MainForm
.App.getGraphics(),
0, y, MainForm
.App.getGraphics().getWidth(), y, GRID_COLOR
);
y
+= gridSize
;
}
}
}
}