OSDN Git Service

Merge pull request #521 from Lemoncog/master
[mikumikustudio/libgdx-mikumikustudio.git] / tests / gdx-tests / src / com / badlogic / gdx / tests / Bresenham2Test.java
1 package com.badlogic.gdx.tests;
2
3 import com.badlogic.gdx.Gdx;
4 import com.badlogic.gdx.graphics.Color;
5 import com.badlogic.gdx.graphics.GL20;
6 import com.badlogic.gdx.graphics.Pixmap;
7 import com.badlogic.gdx.graphics.Texture;
8 import com.badlogic.gdx.graphics.Pixmap.Format;
9 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
10 import com.badlogic.gdx.math.Bresenham2;
11 import com.badlogic.gdx.math.GridPoint2;
12 import com.badlogic.gdx.math.Vector2;
13 import com.badlogic.gdx.tests.utils.GdxTest;
14
15 public class Bresenham2Test extends GdxTest {
16         SpriteBatch batch;
17         Texture result;
18         
19         @Override
20         public void create () {
21                 Pixmap pixmap = new Pixmap(512, 512, Format.RGBA8888);
22                 pixmap.setColor(Color.WHITE);
23                 
24                 Bresenham2 bresenham = new Bresenham2();
25                 for(GridPoint2 point: bresenham.line(0, 0, 512, 512)) pixmap.drawPixel(point.x, point.y);
26                 for(GridPoint2 point: bresenham.line(512, 0, 0, 512)) pixmap.drawPixel(point.x, point.y);
27                 for(GridPoint2 point: bresenham.line(0, 0, 512, 256)) pixmap.drawPixel(point.x, point.y);
28                 for(GridPoint2 point: bresenham.line(512, 0, 0, 256)) pixmap.drawPixel(point.x, point.y);
29                 
30                 result = new Texture(pixmap);
31                 batch = new SpriteBatch();
32         }
33
34         @Override
35         public void render () {
36                 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
37                 batch.begin();
38                 batch.draw(result, 0, 0);
39                 batch.end();
40         }
41 }