本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.calculateScissors()
方法的一些代码示例,展示了Stage.calculateScissors()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.calculateScissors()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:calculateScissors
[英]Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix.
[中]使用批次的当前变换矩阵从局部坐标计算窗口剪刀坐标。
代码示例来源:origin: libgdx/libgdx
/** Clips the specified screen aligned rectangle, specified relative to the transform matrix of the stage's Batch. The
* transform matrix and the stage's camera must not have rotational components. Calling this method must be followed by a call
* to {@link #clipEnd()} if true is returned.
* @return false if the clipping area is zero and no drawing should occur.
* @see ScissorStack */
public boolean clipBegin (float x, float y, float width, float height) {
if (width <= 0 || height <= 0) return false;
Rectangle tableBounds = Rectangle.tmp;
tableBounds.x = x;
tableBounds.y = y;
tableBounds.width = width;
tableBounds.height = height;
Stage stage = this.stage;
Rectangle scissorBounds = Pools.obtain(Rectangle.class);
stage.calculateScissors(tableBounds, scissorBounds);
if (ScissorStack.pushScissors(scissorBounds)) return true;
Pools.free(scissorBounds);
return false;
}
代码示例来源:origin: libgdx/libgdx
/** Clips the specified screen aligned rectangle, specified relative to the transform matrix of the stage's Batch. The
* transform matrix and the stage's camera must not have rotational components. Calling this method must be followed by a call
* to {@link #clipEnd()} if true is returned.
* @return false if the clipping area is zero and no drawing should occur.
* @see ScissorStack */
public boolean clipBegin (float x, float y, float width, float height) {
if (width <= 0 || height <= 0) return false;
Rectangle tableBounds = Rectangle.tmp;
tableBounds.x = x;
tableBounds.y = y;
tableBounds.width = width;
tableBounds.height = height;
Stage stage = this.stage;
Rectangle scissorBounds = Pools.obtain(Rectangle.class);
stage.calculateScissors(tableBounds, scissorBounds);
if (ScissorStack.pushScissors(scissorBounds)) return true;
Pools.free(scissorBounds);
return false;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void draw (Batch batch, float parentAlpha) {
validate();
Color color = getColor();
float alpha = color.a * parentAlpha;
applyTransform(batch, computeTransform());
if (firstWidget != null && firstWidget.isVisible()) {
batch.flush();
getStage().calculateScissors(firstWidgetBounds, tempScissors);
if (ScissorStack.pushScissors(tempScissors)) {
firstWidget.draw(batch, alpha);
batch.flush();
ScissorStack.popScissors();
}
}
if (secondWidget != null && secondWidget.isVisible()) {
batch.flush();
getStage().calculateScissors(secondWidgetBounds, tempScissors);
if (ScissorStack.pushScissors(tempScissors)) {
secondWidget.draw(batch, alpha);
batch.flush();
ScissorStack.popScissors();
}
}
batch.setColor(color.r, color.g, color.b, alpha);
style.handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
resetTransform(batch);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void draw (Batch batch, float parentAlpha) {
validate();
Color color = getColor();
float alpha = color.a * parentAlpha;
applyTransform(batch, computeTransform());
if (firstWidget != null && firstWidget.isVisible()) {
batch.flush();
getStage().calculateScissors(firstWidgetBounds, tempScissors);
if (ScissorStack.pushScissors(tempScissors)) {
firstWidget.draw(batch, alpha);
batch.flush();
ScissorStack.popScissors();
}
}
if (secondWidget != null && secondWidget.isVisible()) {
batch.flush();
getStage().calculateScissors(secondWidgetBounds, tempScissors);
if (ScissorStack.pushScissors(tempScissors)) {
secondWidget.draw(batch, alpha);
batch.flush();
ScissorStack.popScissors();
}
}
batch.setColor(color.r, color.g, color.b, alpha);
style.handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
resetTransform(batch);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void draw (Batch batch, float parentAlpha) {
if (widget == null) return;
validate();
// Setup transform for this group.
applyTransform(batch, computeTransform());
if (scrollX) hKnobBounds.x = hScrollBounds.x + (int)((hScrollBounds.width - hKnobBounds.width) * getVisualScrollPercentX());
if (scrollY)
vKnobBounds.y = vScrollBounds.y + (int)((vScrollBounds.height - vKnobBounds.height) * (1 - getVisualScrollPercentY()));
updateWidgetPosition();
// Draw the background ninepatch.
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
if (style.background != null) style.background.draw(batch, 0, 0, getWidth(), getHeight());
// Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to
// project those to screen coordinates for OpenGL ES to consume.
getStage().calculateScissors(widgetAreaBounds, scissorBounds);
// Enable scissors for widget area and draw the widget.
batch.flush();
if (ScissorStack.pushScissors(scissorBounds)) {
drawChildren(batch, parentAlpha);
batch.flush();
ScissorStack.popScissors();
}
// Render scrollbars and knobs on top if they will be visible
float alpha = color.a * parentAlpha * Interpolation.fade.apply(fadeAlpha / fadeAlphaSeconds);
drawScrollBars(batch, color.r, color.g, color.b, alpha);
resetTransform(batch);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void draw (Batch batch, float parentAlpha) {
if (widget == null) return;
validate();
// Setup transform for this group.
applyTransform(batch, computeTransform());
if (scrollX) hKnobBounds.x = hScrollBounds.x + (int)((hScrollBounds.width - hKnobBounds.width) * getVisualScrollPercentX());
if (scrollY)
vKnobBounds.y = vScrollBounds.y + (int)((vScrollBounds.height - vKnobBounds.height) * (1 - getVisualScrollPercentY()));
updateWidgetPosition();
// Draw the background ninepatch.
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
if (style.background != null) style.background.draw(batch, 0, 0, getWidth(), getHeight());
// Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to
// project those to screen coordinates for OpenGL ES to consume.
getStage().calculateScissors(widgetAreaBounds, scissorBounds);
// Enable scissors for widget area and draw the widget.
batch.flush();
if (ScissorStack.pushScissors(scissorBounds)) {
drawChildren(batch, parentAlpha);
batch.flush();
ScissorStack.popScissors();
}
// Render scrollbars and knobs on top if they will be visible
float alpha = color.a * parentAlpha * Interpolation.fade.apply(fadeAlpha / fadeAlphaSeconds);
drawScrollBars(batch, color.r, color.g, color.b, alpha);
resetTransform(batch);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Clips the specified screen aligned rectangle, specified relative to the transform matrix of the stage's Batch. The
* transform matrix and the stage's camera must not have rotational components. Calling this method must be followed by a call
* to {@link #clipEnd()} if true is returned.
* @return false if the clipping area is zero and no drawing should occur.
* @see ScissorStack */
public boolean clipBegin (float x, float y, float width, float height) {
if (width <= 0 || height <= 0) return false;
Rectangle tableBounds = Rectangle.tmp;
tableBounds.x = x;
tableBounds.y = y;
tableBounds.width = width;
tableBounds.height = height;
Stage stage = this.stage;
Rectangle scissorBounds = Pools.obtain(Rectangle.class);
stage.calculateScissors(tableBounds, scissorBounds);
if (ScissorStack.pushScissors(scissorBounds)) return true;
Pools.free(scissorBounds);
return false;
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
public void draw(Batch batch, float parentAlpha) {
batch.flush();
getStage().calculateScissors(widgetAreaBounds.set(getX(), getY(), getWidth(), getHeight()), scissorBounds);
if (ScissorStack.pushScissors(scissorBounds)) {
super.draw(batch, parentAlpha);
batch.flush();
ScissorStack.popScissors();
}
}
代码示例来源:origin: kotcrab/vis-ui
@Override
public void draw (Batch batch, float parentAlpha) {
validate();
Color color = getColor();
applyTransform(batch, computeTransform());
// Matrix4 transform = batch.getTransformMatrix();
if (firstWidget != null) {
getStage().calculateScissors(firstWidgetBounds, firstScissors);
if (ScissorStack.pushScissors(firstScissors)) {
if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a);
batch.flush();
ScissorStack.popScissors();
}
}
if (secondWidget != null) {
getStage().calculateScissors(secondWidgetBounds, secondScissors);
if (ScissorStack.pushScissors(secondScissors)) {
if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a);
batch.flush();
ScissorStack.popScissors();
}
}
Drawable handle = style.handle;
if (mouseOnHandle && isTouchable() && style.handleOver != null) handle = style.handleOver;
batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
resetTransform(batch);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
@Override
public void draw (Batch batch, float parentAlpha) {
validate();
Color color = getColor();
float alpha = color.a * parentAlpha;
applyTransform(batch, computeTransform());
if (firstWidget != null && firstWidget.isVisible()) {
batch.flush();
getStage().calculateScissors(firstWidgetBounds, tempScissors);
if (ScissorStack.pushScissors(tempScissors)) {
firstWidget.draw(batch, alpha);
batch.flush();
ScissorStack.popScissors();
}
}
if (secondWidget != null && secondWidget.isVisible()) {
batch.flush();
getStage().calculateScissors(secondWidgetBounds, tempScissors);
if (ScissorStack.pushScissors(tempScissors)) {
secondWidget.draw(batch, alpha);
batch.flush();
ScissorStack.popScissors();
}
}
batch.setColor(color.r, color.g, color.b, alpha);
style.handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
resetTransform(batch);
}
代码示例来源:origin: mbrlabs/Mundus
@Override
public void draw(Batch batch, float parentAlpha) {
validate();
Color color = getColor();
applyTransform(batch, computeTransform());
// Matrix4 transform = batch.getTransformMatrix();
if (firstWidget != null) {
getStage().calculateScissors(firstWidgetBounds, firstScissors);
if (ScissorStack.pushScissors(firstScissors)) {
if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a);
batch.flush();
ScissorStack.popScissors();
}
}
if (secondWidget != null) {
getStage().calculateScissors(secondWidgetBounds, secondScissors);
if (ScissorStack.pushScissors(secondScissors)) {
if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a);
batch.flush();
ScissorStack.popScissors();
}
}
Drawable handle = style.handle;
if (mouseOnHandle && isTouchable() && style.handleOver != null) handle = style.handleOver;
batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
resetTransform(batch);
}
代码示例来源:origin: kotcrab/vis-ui
@Override
public void draw (Batch batch, float parentAlpha) {
validate();
Color color = getColor();
applyTransform(batch, computeTransform());
SnapshotArray<Actor> actors = getChildren();
for (int i = 0; i < actors.size; i++) {
Actor actor = actors.get(i);
Rectangle bounds = widgetBounds.get(i);
Rectangle scissor = scissors.get(i);
getStage().calculateScissors(bounds, scissor);
if (ScissorStack.pushScissors(scissor)) {
if (actor.isVisible()) actor.draw(batch, parentAlpha * color.a);
batch.flush();
ScissorStack.popScissors();
}
}
batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
Drawable handle = style.handle;
Drawable handleOver = style.handle;
if (isTouchable() && style.handleOver != null) handleOver = style.handleOver;
for (Rectangle rect : handleBounds) {
if (this.handleOver == rect) {
handleOver.draw(batch, rect.x, rect.y, rect.width, rect.height);
} else {
handle.draw(batch, rect.x, rect.y, rect.width, rect.height);
}
}
resetTransform(batch);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
@Override
public void draw (Batch batch, float parentAlpha) {
if (widget == null) return;
validate();
// Setup transform for this group.
applyTransform(batch, computeTransform());
if (scrollX) hKnobBounds.x = hScrollBounds.x + (int)((hScrollBounds.width - hKnobBounds.width) * getVisualScrollPercentX());
if (scrollY)
vKnobBounds.y = vScrollBounds.y + (int)((vScrollBounds.height - vKnobBounds.height) * (1 - getVisualScrollPercentY()));
updateWidgetPosition();
// Draw the background ninepatch.
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
if (style.background != null) style.background.draw(batch, 0, 0, getWidth(), getHeight());
// Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to
// project those to screen coordinates for OpenGL ES to consume.
getStage().calculateScissors(widgetAreaBounds, scissorBounds);
// Enable scissors for widget area and draw the widget.
batch.flush();
if (ScissorStack.pushScissors(scissorBounds)) {
drawChildren(batch, parentAlpha);
batch.flush();
ScissorStack.popScissors();
}
// Render scrollbars and knobs on top if they will be visible
float alpha = color.a * parentAlpha * Interpolation.fade.apply(fadeAlpha / fadeAlphaSeconds);
drawScrollBars(batch, color.r, color.g, color.b, alpha);
resetTransform(batch);
}
代码示例来源:origin: mbrlabs/Mundus
@Override
public void draw(Batch batch, float parentAlpha) {
validate();
Color color = getColor();
applyTransform(batch, computeTransform());
SnapshotArray<Actor> actors = getChildren();
for (int i = 0; i < actors.size; i++) {
Actor actor = actors.get(i);
Rectangle bounds = widgetBounds.get(i);
Rectangle scissor = scissors.get(i);
getStage().calculateScissors(bounds, scissor);
if (ScissorStack.pushScissors(scissor)) {
if (actor.isVisible()) actor.draw(batch, parentAlpha * color.a);
batch.flush();
ScissorStack.popScissors();
}
}
batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
Drawable handle = style.handle;
Drawable handleOver = style.handle;
if (isTouchable() && style.handleOver != null) handleOver = style.handleOver;
for (Rectangle rect : handleBounds) {
if (this.handleOver == rect) {
handleOver.draw(batch, rect.x, rect.y, rect.width, rect.height);
} else {
handle.draw(batch, rect.x, rect.y, rect.width, rect.height);
}
}
resetTransform(batch);
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
getStage().calculateScissors(bounds, scissors);
内容来源于网络,如有侵权,请联系作者删除!