本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.utils.Drawable.draw方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.draw方法的具體用法?Java Drawable.draw怎麽用?Java Drawable.draw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.scenes.scene2d.utils.Drawable
的用法示例。
在下文中一共展示了Drawable.draw方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fillRoundedRect
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
@Override
public void fillRoundedRect(float x, float y, float w, float h, int cornerRadius) {
Drawable drawable = getRoundedRectDrawable(cornerRadius);
Color originalColor = null;
ensureSpriteBatchOpen();
if (brushType == BrushType.COLOR) {
originalColor = spriteBatch.getColor();
Color color = getAlphaMultiplied(colorBrush);
spriteBatch.setColor(color);
freeColor(color);
}
drawable.draw(spriteBatch, x, viewportSize.y - y - h, w, h);
if (originalColor != null) {
spriteBatch.setColor(originalColor);
}
}
示例2: drawGap
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
private void drawGap(int i, Batch batch) {
Drawable headerGap;
if (i == selectedIndex) {
//current active
headerGap = style.activeBorderRight;
} else if (i == selectedIndex - 1) {
//next active
headerGap = style.activeBorderLeft;
} else {
headerGap = style.inactiveBorder;
}
if (headerGap != null) {
headerGap.draw(
batch,
getX() + headerWidth * (i + 1) + headersLeftOffset + i * headersBetweenOffset,
getY() + contentHeight,
headersBetweenOffset,
getHeight() - contentHeight
);
}
}
示例3: drawBackground
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
protected void drawBackground(Batch batch, float parentAlpha, float x, float y) {
Drawable background = this.getBackground();
if (background == null) return;
Color color = getColor();
// restore alpha if item disabled, draw background never with alpha
if (!this.mIsEnabled)
parentAlpha *= 4f;
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
background.draw(batch, x, y, getWidth(), getHeight());
}
示例4: draw
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
@Override public void draw(Batch batch, float parentAlpha) {
if (selectedIndex == -1)
return;
validate();
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
drawContentBackground(batch);
drawLeftBorder(batch);
drawRightBorder(batch);
for (int i = 0; i < headers.size; i++) {
if (i != headers.size - 1)
drawGap(i, batch);
Drawable headerBackground;
if (selectedIndex == i) {
headerBackground = style.active;
} else {
headerBackground = style.inactive;
}
if (headerBackground != null) {
headerBackground.draw(
batch,
getX() + headerWidth * i + headersLeftOffset + i * headersBetweenOffset - 0.5f,
getY() + contentHeight,
headerWidth + 1f,
getHeight() - contentHeight
);
}
}
super.draw(batch, parentAlpha);
}
示例5: drawRightBorder
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
private void drawRightBorder(Batch batch) {
Drawable rightBorder;
if (selectedIndex == headers.size - 1) {
rightBorder = style.activeBorderRightEdge;
} else {
rightBorder = style.inactiveBorderRightEdge;
}
if (rightBorder != null) {
float x = getX() + getWidth() - headersRightOffset;
float y = getY() + contentHeight;
rightBorder.draw(batch, x, y, headersRightOffset, getHeight() - contentHeight);
}
}
示例6: drawLeftBorder
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
private void drawLeftBorder(Batch batch) {
Drawable leftBorder;
if (selectedIndex == 0) {
leftBorder = style.activeBorderLeftEdge;
} else {
leftBorder = style.inactiveBorderLeftEdge;
}
if (leftBorder != null) {
leftBorder.draw(batch, getX(), getY() + contentHeight, headersLeftOffset, getHeight() - contentHeight);
}
}
示例7: drawBackground
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
private void drawBackground(Batch batch, float parentAlpha) {
Color color = batch.getColor();
batch.setColor(1, 1, 1, 1);
//draw frame
Drawable frame = null;
switch (state) {
case COMPASS:
frame = style.frameCompasAlign;
break;
case USER:
frame = style.frameUserRotate;
break;
case NORTH:
frame = style.frameNorthOrient;
break;
}
if (frame != null) {
frame.draw(batch, rec_frame.getX(), rec_frame.getY(), rec_frame.getWidth(), rec_frame.getHeight());
}
oldTransform.set(batch.getTransformMatrix());
//draw scale
if (style.scale != null) {
tmp.set(oldTransform);
tmp.mul(transform_scale);
batch.setTransformMatrix(tmp);
style.scale.draw(batch, rec_scale.getX(), rec_scale.getY(), rec_scale.getWidth(), rec_scale.getHeight());
}
//draw arrow
if (style.arrow != null) {
tmp.set(oldTransform);
tmp.mul(transform_arrow);
batch.setTransformMatrix(tmp);
style.arrow.draw(batch, rec_arrow.getX(), rec_arrow.getY(), rec_arrow.getWidth(), rec_arrow.getHeight());
}
batch.setTransformMatrix(oldTransform);
batch.setColor(color);
}
示例8: draw
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
ProgressBarStyle style = this.style;
final Drawable bg = style.background;
final Drawable knobBefore = style.progress;
Color color = getColor();
float x = getX();
float y = getY();
float width = getWidth();
float height = getHeight();
float value = getVisualValue();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
if (vertical) {
bg.draw(batch, x + (int) ((width - bg.getMinWidth()) * 0.5f), y, bg.getMinWidth(), height);
float progressPosHeight = height - (bg.getTopHeight() + bg.getBottomHeight());
if (min != max) {
progressPos = (value - min) / (max - min) * progressPosHeight;
progressPos = Math.max(0, progressPos);
progressPos = Math.min(progressPosHeight, progressPos) + bg.getBottomHeight();
}
if (knobBefore != null) {
knobBefore.draw(batch, x + (int) ((width - knobBefore.getMinWidth()) * 0.5f), y, knobBefore.getMinWidth(),
(int) progressPos);
}
} else {
bg.draw(batch, x, y + (int) ((height - bg.getMinHeight()) * 0.5f), width, bg.getMinHeight());
float progressPosWidth = width - (bg.getLeftWidth() + bg.getRightWidth());
if (min != max) {
progressPos = (value - min) / (max - min) * progressPosWidth;
progressPos = Math.max(0, progressPos);
progressPos = Math.min(progressPosWidth, progressPos) + bg.getLeftWidth();
}
if (knobBefore != null) {
knobBefore.draw(batch, x, y + (int) ((height - knobBefore.getMinHeight()) * 0.5f), (int) progressPos,
knobBefore.getMinHeight());
}
}
super.draw(batch, parentAlpha);
}