List of usage examples for com.badlogic.gdx.graphics Color Color
public Color(Color color)
From source file:seventh.client.gfx.effects.particle_system.Emitters.java
License:Open Source License
public static Emitter newGunSmokeEmitter(final ClientEntity entity, int emitterTimeToLive) { int maxParticles = 1500; final int maxSpread = 5; final Vector2f tmp = new Vector2f(entity.getPos()); final Vector2f vel = entity.getFacing(); Emitter emitter = new Emitter(tmp, emitterTimeToLive, maxParticles).setName("GunSmokeEmitter") .setDieInstantly(false);// w ww . ja va 2 s . c o m BatchedParticleGenerator gen = new BatchedParticleGenerator(0, 4) .addSingleParticleGenerator( new RandomColorSingleParticleGenerator(new Color(0xDCDCDCff), new Color(0xD3D3D3ff))) .addSingleParticleGenerator(new SingleParticleGenerator() { @Override public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) { particles.color[index].a = 0.32f; if (maxSpread > 0) { Random r = particles.emitter.getRandom(); Vector2f pos = particles.pos[index]; pos.set(1, 0); Vector2f.Vector2fRotate(pos, Math.toRadians(r.nextInt(360)), pos); Vector2f.Vector2fMA(entity.getPos(), entity.getFacing(), 25.0f, tmp); Vector2f.Vector2fMA(tmp, pos, r.nextInt(maxSpread), pos); } } }).addSingleParticleGenerator(new RandomRotationSingleParticleGenerator()) .addSingleParticleGenerator(new RandomScaleSingleParticleGenerator(0.25f, 0.30f)) .addSingleParticleGenerator(new RandomSpeedSingleParticleGenerator(1, 1)) .addSingleParticleGenerator(new RandomVelocitySingleParticleGenerator(vel, 130)) .addSingleParticleGenerator(new RandomTimeToLiveSingleParticleGenerator(3800, 4000)) .addSingleParticleGenerator(new RandomSpriteSingleParticleGenerator(Art.smokeImage)); emitter.addParticleGenerator(gen); emitter.addParticleUpdater(new KillUpdater()); emitter.addParticleUpdater(new KillIfAttachedIsDeadUpdater()); emitter.addParticleUpdater(new RandomMovementParticleUpdater(20)); //emitter.addParticleUpdater(new MovementParticleUpdater(0, 40f)); emitter.addParticleUpdater(new AlphaDecayUpdater(0f, 0.9898f)); emitter.addParticleRenderer(new SpriteParticleRenderer()); return emitter; }
From source file:seventh.client.gfx.effects.particle_system.Emitters.java
License:Open Source License
public static Emitter newBulletTracerEmitter(Vector2f pos, int emitterTimeToLive) { int maxParticles = 68; final Emitter emitter = new Emitter(pos, emitterTimeToLive, maxParticles).setName("BulletTracerEmitter") .setDieInstantly(false);// w ww . ja v a2s . c o m BatchedParticleGenerator gen = new BatchedParticleGenerator(0, maxParticles) .addSingleParticleGenerator( new RandomColorSingleParticleGenerator(new Color(0xffbA00ff), new Color(0xffff00ff))) .addSingleParticleGenerator(new SingleParticleGenerator() { @Override public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) { particles.color[index].a = 0.0f; } }).addSingleParticleGenerator(new SetPositionSingleParticleGenerator()); emitter.addParticleGenerator(gen); emitter.addParticleUpdater(new ParticleUpdater() { @Override public void update(TimeStep timeStep, ParticleData particles) { ClientEntity ent = emitter.attachedTo(); if (ent != null) { Vector2f pos = ent.getCenterPos(); Vector2f vel = ent.getMovementDir(); for (int index = 0; index < particles.numberOfAliveParticles; index++) { float offset = index; Vector2f.Vector2fMS(pos, vel, offset, particles.pos[index]); float percentange = (float) index / particles.numberOfAliveParticles; particles.color[index].a = 0.9512f * (1f - percentange); } } else { for (int index = 0; index < particles.numberOfAliveParticles; index++) { particles.color[index].a = 0f; } } } }); emitter.addParticleUpdater(new KillIfAttachedIsDeadUpdater()); emitter.addParticleRenderer(new RectParticleRenderer(2, 2)); return emitter; }
From source file:seventh.client.gfx.effects.particle_system.Emitters.java
License:Open Source License
public static Emitter newBulletImpactEmitter(Vector2f pos, Vector2f targetVel) { // 5, 5200, 4000, 0, 60); // int maxParticles, int emitterTimeToLive, int particleTimeToLive, int timeToNextSpawn, int maxSpread) { Vector2f vel = targetVel.isZero() ? new Vector2f(-1.0f, -1.0f) : new Vector2f(-targetVel.x * 1.0f, -targetVel.y * 1.0f); Emitter emitter = new Emitter(pos, 200, 30).setName("BulletImpactEmitter").setDieInstantly(false); BatchedParticleGenerator gen = new BatchedParticleGenerator(0, 30); gen.addSingleParticleGenerator(new SingleParticleGenerator() { @Override//from w w w .j a va 2 s .co m public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) { particles.speed[index] = 125f; } }).addSingleParticleGenerator(new SetPositionSingleParticleGenerator()) .addSingleParticleGenerator( new RandomColorSingleParticleGenerator(new Color(0x8B7355ff), new Color(0x8A7355ff))) .addSingleParticleGenerator(new RandomVelocitySingleParticleGenerator(vel, 60)) .addSingleParticleGenerator(new RandomTimeToLiveSingleParticleGenerator(200, 250)); emitter.addParticleGenerator(gen); emitter.addParticleUpdater(new KillUpdater()); emitter.addParticleUpdater(new RandomMovementParticleUpdater(85)); emitter.addParticleUpdater(new AlphaDecayUpdater(0f, 0.82718f)); emitter.addParticleRenderer(new CircleParticleRenderer()); return emitter; }
From source file:seventh.client.gfx.effects.particle_system.Emitters.java
License:Open Source License
public static Emitter newTankTrackSplatterEmitter(Vector2f pos, Vector2f targetVel) { // 5, 5200, 4000, 0, 60); // int maxParticles, int emitterTimeToLive, int particleTimeToLive, int timeToNextSpawn, int maxSpread) { Vector2f vel = targetVel.isZero() ? new Vector2f(-1.0f, -1.0f) : new Vector2f(-targetVel.x * 1.0f, -targetVel.y * 1.0f); Emitter emitter = new Emitter(pos, 200, 30).setName("BulletImpactEmitter").setDieInstantly(false); BatchedParticleGenerator gen = new BatchedParticleGenerator(0, 30); gen.addSingleParticleGenerator(new SingleParticleGenerator() { @Override/*from ww w. j a v a 2 s . c om*/ public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) { particles.speed[index] = 125f; } }).addSingleParticleGenerator(new SetPositionSingleParticleGenerator()) .addSingleParticleGenerator( new RandomColorSingleParticleGenerator(new Color(0x8B7355ff), new Color(0x8A7355ff))) .addSingleParticleGenerator(new RandomVelocitySingleParticleGenerator(vel, 30)) .addSingleParticleGenerator(new RandomTimeToLiveSingleParticleGenerator(200, 250)); emitter.addParticleGenerator(gen); emitter.addParticleUpdater(new KillUpdater()); emitter.addParticleUpdater(new RandomMovementParticleUpdater(85)); emitter.addParticleUpdater(new AlphaDecayUpdater(0f, 0.72718f)); emitter.addParticleRenderer(new CircleParticleRenderer()); return emitter; }
From source file:seventh.client.gfx.effects.particle_system.Emitters.java
License:Open Source License
public static Emitter newSpawnEmitter(Vector2f pos, int emitterTimeToLive) { int maxParticles = 40; int maxSpread = 45; Emitter emitter = new Emitter(pos, emitterTimeToLive, maxParticles).setName("SpawnEmitter") .setDieInstantly(false);//ww w .j a v a2 s .c om BatchedParticleGenerator gen = new BatchedParticleGenerator(100, 2) .addSingleParticleGenerator(new RandomColorSingleParticleGenerator(new Color(0xffa701ff), new Color(0xeeb803ff), new Color(0xffb805ff))) .addSingleParticleGenerator(new SingleParticleGenerator() { @Override public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) { particles.color[index].a = 0.82f; } }).addSingleParticleGenerator(new RandomPositionInRadiusSingleParticleGenerator(maxSpread)) .addSingleParticleGenerator(new RandomScaleSingleParticleGenerator(0.15f, 0.55f)) .addSingleParticleGenerator(new RandomSpeedSingleParticleGenerator(1, 1)) .addSingleParticleGenerator(new RandomVelocitySingleParticleGenerator(new Vector2f(1, 0), 180)) .addSingleParticleGenerator(new RandomTimeToLiveSingleParticleGenerator(1800, 2300)) .addSingleParticleGenerator(new RandomSpriteSingleParticleGenerator(Art.smokeImage)); emitter.addParticleGenerator(gen); emitter.addParticleUpdater(new KillUpdater()); emitter.addParticleUpdater(new KillIfAttachedIsDeadUpdater()); emitter.addParticleUpdater(new RandomMovementParticleUpdater(40)); //emitter.addParticleUpdater(new MovementParticleUpdater(0, 40f)); emitter.addParticleUpdater(new AlphaDecayUpdater(0f, 0.96898f)); emitter.addParticleRenderer(new SpriteParticleRenderer()); return emitter; }
From source file:seventh.client.gfx.TextureUtil.java
License:Open Source License
public static Pixmap toWhite(Pixmap img) { Pixmap alpha = new Pixmap(img.getWidth(), img.getHeight(), Format.RGBA8888); //alpha.drawPixmap(img, 0, 0); int width = alpha.getWidth(); int height = alpha.getHeight(); //alpha.setColor(0xff00009f); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int col = img.getPixel(x, y); Color color = new Color(col); if (color.a > 0.2f) { alpha.drawPixel(x, y, Color.WHITE.toIntBits()); }/*from ww w . j a va 2s.c om*/ } } img.dispose(); return alpha; }
From source file:skyranger.game.PlayScreen.java
License:Apache License
@Override public void render(float delta) { Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); this.world.step(TIMESTEP, VELOCITYITERATIONS, POSITIONITERATIONS); // if (!movement.isZero()) // {//from w ww. j a v a2s. c o m // System.out.println(movement); // } this.player.getBody().applyForceToCenter(movement, true); camera.position.set(this.player.getBody().getPosition(), 0); camera.update(); batch.setProjectionMatrix(camera.combined); batch.begin(); for (IBox2dObject obj : ObjectsManager.getObjects().values()) { ((Wall) obj).getBodySprite().draw(batch, camera); } player.draw(batch, camera); cursor.draw(camera, player); batch.end(); if ((this.getSelectedObjId()) != "") { IBox2dObject obj = ObjectsManager.get(this.getSelectedObjId()); DrawPrimitives.DrawBox(obj.getBody().getPosition(), obj.getSize(), 2f, new Color(Color.ORANGE), camera.combined, obj.getBody().getAngle() * MathUtils.radiansToDegrees); } if (Mouse.isInsideWindow()) { try { Mouse.setNativeCursor(emptyCursor); } catch (LWJGLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { // Gdx.input.setCursorCatched(true); try { Mouse.setNativeCursor(null); } catch (LWJGLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (isDebug) { this.debugRenderer.render(this.world, this.camera.combined); } }
From source file:spine.Skeleton.java
License:Open Source License
/** Copy constructor. */ public Skeleton(Skeleton skeleton) { if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); data = skeleton.data;/* www . j a va2 s .co m*/ bones = new Array(skeleton.bones.size); for (Bone bone : skeleton.bones) { Bone parent = bone.parent == null ? null : bones.get(skeleton.bones.indexOf(bone.parent, true)); bones.add(new Bone(bone, this, parent)); } slots = new Array(skeleton.slots.size); for (Slot slot : skeleton.slots) { Bone bone = bones.get(skeleton.bones.indexOf(slot.bone, true)); slots.add(new Slot(slot, bone)); } drawOrder = new Array(slots.size); for (Slot slot : skeleton.drawOrder) drawOrder.add(slots.get(skeleton.slots.indexOf(slot, true))); ikConstraints = new Array(skeleton.ikConstraints.size); for (IkConstraint ikConstraint : skeleton.ikConstraints) ikConstraints.add(new IkConstraint(ikConstraint, this)); transformConstraints = new Array(skeleton.transformConstraints.size); for (TransformConstraint transformConstraint : skeleton.transformConstraints) transformConstraints.add(new TransformConstraint(transformConstraint, this)); skin = skeleton.skin; color = new Color(skeleton.color); time = skeleton.time; flipX = skeleton.flipX; flipY = skeleton.flipY; updateCache(); }
From source file:ta.shape3D.Triangle3D.java
License:Apache License
/** * Create and load a triangle by using the stream defined * @param dis the stream which contains the information of the triangle to load * @return the loaded triangle /*from w w w. ja v a 2s . c o m*/ */ public static Triangle3D load(DataInputStream dis) { Triangle3D retour = null; try { retour = new Triangle3D(dis.readInt()); for (int cpt = 0; cpt < 3; cpt++) { retour.points[cpt] = new Vector3(dis.readFloat(), dis.readFloat(), dis.readFloat()); } for (int cpt = 0; cpt < 3; cpt++) { retour.pointsTexture[cpt] = new Vector2(dis.readFloat(), dis.readFloat()); } for (int cpt = 0; cpt < 3; cpt++) { int a = dis.readUnsignedByte(); int r = dis.readUnsignedByte(); int g = dis.readUnsignedByte(); int b = dis.readUnsignedByte(); retour.couleurs[cpt] = new Color(Color.toIntBits(a, b, g, r)); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return retour; }
From source file:ve.ucv.ciens.ccg.nxtar.components.FadeEffectComponent.java
License:Apache License
/** * <p>Creates a fade to/from white depending on the parameter.</p> * // w w w . j a va 2 s .c o m * @param fadeIn True to create a fade FROM white, false for a fade TO white. */ public FadeEffectComponent(boolean fadeIn) { if (fadeIn) { this.alpha = new MutableFloat(1.0f); this.fadeIn = Tween.to(alpha, 0, 2.0f).target(0.0f).ease(TweenEquations.easeInQuint); this.fadeOut = null; } else { this.alpha = new MutableFloat(0.0f); this.fadeOut = Tween.to(alpha, 0, 2.5f).target(1.0f).ease(TweenEquations.easeInQuint); this.fadeIn = null; } color = new Color(Color.WHITE); }