pixmap 그림 그리 기

전송:http://blog.csdn.net/hjd_love_zzt/article/details/21528449
1. 초기 화 및 일반 API
pixmap = new Pixmap(800, 480, Format.RGBA8888);
		pixmap.setColor(Color.BLUE);//  pixmap   
		pixmap.drawLine(0, 0, 100, 100);//  
		pixmap.drawLine(200, 0, 300, 100);//  (x1,y1)、  (x2,y2)
		pixmap.fillCircle(150, 150, 32);//    .(x,y)   
		pixmap.drawCircle(250, 100, 50);//    .(x,y)   
		pixmap.drawRectangle(0, 0, 150, 150);//     .  (x,y),(width,height)
		pixmap.fillRectangle(0, 160, 100, 100);//     .  (x,y),(width,height)
		/**
		 * pixmap.getHeight():   pixmap   
		 * pixmap.getWidth():   pixmap   
		 * pixmap.getFormat():   pixmap   
		 */
		System.out.println("pixmap.getHeight(): " + pixmap.getHeight() + ",pixmap.getWidth( " + pixmap.getWidth() + ", pixmap.getFormat()" + pixmap.getFormat());

2. 예 를 들 어
package com.example.groupactiontest;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Input.Peripheral;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;

public class MyGame implements ApplicationListener {

	Stage stage;
	Image image;
	
	SpriteBatch batch;
	Texture texture;
	TextureRegion region;
	Pixmap pixmap;
	
	@Override
	public void create() {
		stage = new Stage(800,480,false);
		
		batch = new SpriteBatch();
		texture = new Texture(1024, 1024, Format.RGBA8888);
		pixmap = new Pixmap(800, 480, Format.RGBA8888);
		
		pixmap.setColor(Color.BLUE);//  pixmap   
		pixmap.drawLine(0, 0, 100, 100);//  
		
		pixmap.setColor(Color.GREEN);
		pixmap.drawLine(100, 100, 200, 0);
		
		pixmap.setColor(Color.ORANGE);
		pixmap.drawLine(200, 0, 300, 100);//  (x1,y1)、  (x2,y2)
		
		pixmap.setColor(Color.WHITE);
		pixmap.fillCircle(150, 150, 32);//    .(x,y)   
		
		pixmap.setColor(Color.RED);
		pixmap.drawCircle(250, 100, 50);//    .(x,y)   
		
		pixmap.setColor(Color.YELLOW);
		pixmap.drawRectangle(0, 0, 150, 150);//     .  (x,y),(width,height)
		
		pixmap.setColor(Color.MAGENTA);
		pixmap.fillRectangle(0, 160, 100, 100);//     .  (x,y),(width,height)
		
		/**
		 * pixmap.getHeight():   pixmap   
		 * pixmap.getWidth():   pixmap   
		 * pixmap.getFormat():   pixmap   
		 */
		System.out.println("pixmap.getHeight(): " + pixmap.getHeight() + ",pixmap.getWidth( " + pixmap.getWidth() + ", pixmap.getFormat()" + pixmap.getFormat());
		
		
		texture.draw(pixmap, 0, 0);// texture    pixmap  
		
		region = new TextureRegion(texture, 800, 480);
		
//		image = new Image(region);
//		stage.addActor(image);
//		
//		Gdx.input.setInputProcessor(stage);
		
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void render() {
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		
		batch.begin();
		
		batch.draw(region, 0, 0);
		
		batch.end();
		
		
//		stage.act();
//		stage.draw();
		
	}

	@Override
	public void resize(int arg0, int arg1) {
		// TODO Auto-generated method stub

	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

}

4. 소스 코드 다운로드
http://download.csdn.net/detail/caihongshijie6/7065437

좋은 웹페이지 즐겨찾기