List of usage examples for com.badlogic.gdx.graphics Color Color
public Color(Color color)
From source file:CB_UI_Base.graphics.Images.VectorDrawable.java
License:Open Source License
private void drawFbo(Batch batch, float x, float y, final float width, final float height, final Matrix4 oriMatrix, Matrix4 thisDrawMatrix) { final int fboScalerWidth = (int) (this.DEFAULT_WIDTH * FBO_SCALER); final int fboScalerHeight = (int) (this.DEFAULT_HEIGHT * FBO_SCALER); if (!RunOnGlSetted && m_fboEnabled && m_fboRegion == null) { RunOnGlSetted = true;/* ww w .ja v a 2s . c o m*/ GL.that.RunOnGL(new IRenderFBO() { @Override public void run() { synchronized (isDisposed) { if (isDisposed.get()) { return; } try { Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST); long start = System.currentTimeMillis(); m_fbo = new FrameBuffer(Format.RGBA8888, fboScalerWidth, fboScalerHeight, false); m_fboRegion = new TextureRegion(m_fbo.getColorBufferTexture()); m_fboRegion.flip(flipX, flipY); m_fbo.begin(); // clear screen Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); GL.batch.setColor(new Color(Color.WHITE)); GL.batch.begin(); Matrix4 matrix = new Matrix4().setToOrtho2D(0, 0, width, height); matrix.scale(FBO_SCALER, FBO_SCALER, 1); GL.batch.setProjectionMatrix(matrix); // draw Background GL.batch.disableBlending(); background.draw(GL.batch, 0, 0, fboScalerWidth, fboScalerHeight); GL.batch.enableBlending(); int count = 0; for (int i = 0, n = drawableList.size(); i < n; i++) { MatrixDrawable drw = drawableList.get(i); if (count++ > 2500) { GL.batch.flush(); count = 0; } matrix = new Matrix4().setToOrtho2D(0, 0, width, height); if (drw.matrix != null) { matrix.mul(drw.matrix.getMatrix4()); } GL.batch.setProjectionMatrix(matrix); drw.drawable.draw(GL.batch, 0, 0, width, height, 0); } if (m_fbo != null) { GL.batch.end(); m_fbo.end(); m_fboEnabled = false; } FBOisDrawed = true; FBO_DrawingTime = System.currentTimeMillis() - start; Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST); GL.batch.setProjectionMatrix(oriMatrix); m_fboEnabled = false; } catch (Exception e) { e.printStackTrace(); } } } }); } if (m_fboRegion != null) { // TODO clear and release the drawables that drawed on m_fboRegion // if first drawing of m_fboRegion batch.draw(m_fboRegion, x, y, width, height); } else { int count = 0; for (int i = 0, n = drawableList.size(); i < n; i++) { MatrixDrawable drw = drawableList.get(i); if (!drw.reaelDraw) continue; if (count++ > 2500) { GL.batch.flush(); count = 0; } Matrix4 matrix = thisDrawMatrix.cpy(); if (drw.matrix != null) matrix.mul(drw.matrix.getMatrix4()); GL.batch.setProjectionMatrix(matrix); drw.drawable.draw(GL.batch, 0, 0, width, height, 0); } } }
From source file:CB_UI_Base.graphics.PolygonDrawable.java
License:Open Source License
@Override public boolean draw(Batch batch, float x, float y, float width, float height, float rotate) { synchronized (isDisposed) { if (isDisposed.get()) return true; if (po == null) { if (this.PAINT.getBitmapShader() == null) { if (texReg == null) createTexRegFromPixMap(); po = new PolygonRegion(texReg, VERTICES, TRIANGLES); } else { Texture inputTex = this.PAINT.getBitmapShader().getTexture(); if (inputTex != null) { inputTex.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); po = new PolygonRegion(new TextureRegion(inputTex, (int) this.WIDTH, (int) this.HEIGHT), VERTICES, TRIANGLES); }/*from ww w . ja v a 2 s .co m*/ } } Color c = batch.getColor(); float a = c.a; float r = c.r; float g = c.g; float b = c.b; if (po == null) return true; if (this.PAINT.getBitmapShader() == null) { GL.setBatchColor(PAINT.getGlColor()); } else { batch.setColor(new Color(Color.WHITE)); } batch.flush(); try { ((PolygonSpriteBatch) batch).draw(po, x, y, width, height); } catch (Exception e) { e.printStackTrace(); } batch.flush(); // reset color batch.setColor(r, g, b, a); } return true; }
From source file:CB_UI_Base.graphics.PolygonDrawable.java
License:Open Source License
private void createTexRegFromPixMap() { if (isDisposed.get()) return;/*from www .jav a 2 s . c o m*/ int w = 2; int h = 2; pix = new Pixmap(w, h, Pixmap.Format.RGB565); pix.setColor(new Color(Color.WHITE)); pix.fillRectangle(0, 0, w, h); try { tex = new Texture(pix); } catch (Exception e) { tex = null; } if (tex != null) { tex.setFilter(TextureFilter.Linear, TextureFilter.MipMapLinearLinear); texReg = new TextureRegion(tex, (int) this.WIDTH, (int) this.HEIGHT); } pix.dispose(); pix = null; }
From source file:com.algodal.gdxscreen.GdxGame.java
License:Apache License
public GdxGame() { screenMap = new ArrayMap<>(); transitionMap = new ArrayMap<>(); assetMap = new ArrayMap<>(); assetManager = new AssetManager(); defaultScreen = new GdxScreen().setGame(this); screenListener = new ScreenListener(); debug = new GdxDebug().setOn(true); //debugging is on by default //I like this kind of coding where I embed debugging within my main //code. I find it useful because it allows me to avoid using large //amount of nested if statements. In this code I do not have to add //comment to the debug code because the tag strings are descriptive. library = new GdxLibrary(); clearColor = new Color(Color.RED); pauseStatus = false; //initially the game is not paused. }
From source file:com.andgate.pokeadot.Pokable.java
License:Open Source License
public Pokable(final PokeADot game, Circle circle, Color color, float timeLimit) { this.game = game; this.color = new Color(color); this.initialCircle = new Circle(circle); this.hittableCircle = new Circle(circle); this.visualCircle = new Circle(circle); this.timeLimit = timeLimit; timeElapsed = NO_TIME;//from w w w . j a v a2 s .c o m activeSpeed = -(initialCircle.radius / timeLimit); implodeSpeed = -(initialCircle.radius / MAX_IMPLODE_TIME); explodeSpeed = initialCircle.radius * EXPLODE_FACTOR / MAX_EXPLODE_TIME; }
From source file:com.codefiddler.libgdx.spinit.Segment.java
License:Apache License
public Segment(Texture texture, Color initialColor, int id, int numberOfSegments) { sprite = new TexturedSprite(texture); this.initialColor = new Color(initialColor); this.initialColor.r = this.initialColor.g + ((0.64f / numberOfSegments) * id); sprite.setColor(this.initialColor); }
From source file:com.commons.color.CustomColorPicker.java
License:Apache License
public CustomColorPicker(String styleName, String title, ColorPickerListener listener) { super(title != null ? title : ""); this.listener = listener; this.style = VisUI.getSkin().get(styleName, ColorPickerStyle.class); this.sizes = VisUI.getSizes(); this.bundle = VisUI.getColorPickerBundle(); if (title == null) getTitleLabel().setText(getText(TITLE)); setModal(true);//from w ww .ja va2s.co m setMovable(true); addCloseButton(); closeOnEscape(); oldColor = new Color(Color.BLACK); color = new Color(Color.BLACK); tmpColor = new Color(Color.BLACK); createColorWidgets(); createUI(); createListeners(); updatePixmaps(); pack(); centerWindow(); setStyle(VisUI.getSkin().get("box", WindowStyle.class)); getTitleLabel().setAlignment(Align.left); pickerCreated = true; }
From source file:com.commons.color.CustomColorPicker.java
License:Apache License
private void createListeners() { restoreButton.addListener(new ChangeListener() { @Override/*from w ww.ja va2 s. c o m*/ public void changed(ChangeEvent event, Actor actor) { setColor(oldColor); } }); okButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (listener != null) listener.finished(new Color(color)); setColor(color); if (closeAfterPickingFinished) fadeOut(); } }); cancelButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { setColor(oldColor); close(); } }); }
From source file:com.commons.color.CustomColorPicker.java
License:Apache License
private void updatePixmaps() { for (int v = 0; v <= 100; v++) { for (int s = 0; s <= 100; s++) { ColorUtils.HSVtoRGB(hBar.getValue(), s, v, tmpColor); palettePixmap.drawPixel(v, 100 - s, Color.rgba8888(tmpColor)); }//from www . ja va2 s . c o m } paletteTexture.draw(palettePixmap, 0, 0); newColor.setColor(color); hBar.redraw(); sBar.redraw(); vBar.redraw(); rBar.redraw(); gBar.redraw(); bBar.redraw(); aBar.redraw(); hexField.setText(color.toString().toUpperCase()); hexField.setCursorPosition(hexField.getMaxLength()); if (listener != null && pickerCreated) listener.changed(new Color(color)); }
From source file:com.commons.color.CustomColorPicker.java
License:Apache License
private void setColor(Color c, boolean updateCurrentColor) { if (updateCurrentColor) { currentColor.setColor(new Color(c)); oldColor = new Color(c); }//from w w w . j a v a2s . c o m color = new Color(c); updateFieldsFromColor(); updatePixmaps(); }