当前位置: 首页>>代码示例>>Java>>正文


Java ShapeFill类代码示例

本文整理汇总了Java中org.newdawn.slick.ShapeFill的典型用法代码示例。如果您正苦于以下问题:Java ShapeFill类的具体用法?Java ShapeFill怎么用?Java ShapeFill使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ShapeFill类属于org.newdawn.slick包,在下文中一共展示了ShapeFill类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: texture

import org.newdawn.slick.ShapeFill; //导入依赖的package包/类
/**
 * Draw the the given shape filled in with a texture.  Only the vertices are set.  
 * The colour has to be set independently of this method.
 * 
 * @param shape The shape to texture.
 * @param image The image to tile across the shape
 * @param scaleX The scale to apply on the x axis for texturing
 * @param scaleY The scale to apply on the y axis for texturing
 * @param fill The fill to apply
 */
public static final void texture(@Nonnull final Shape shape, @Nonnull final Image image, final float scaleX, final float scaleY, @Nonnull final ShapeFill fill) {
    if (!validFill(shape)) {
        return;
    }
    
    Texture t = TextureImpl.getLastBind();
    image.getTexture().bind();
    
    final float center[] = shape.getCenter();
    fill(shape, (shape1, x, y) -> {
        fill.colorAt(shape1, x - center[0], y - center[1]).bind();
        Vector2f offset = fill.getOffsetAt(shape1, x, y);

        x += offset.x;
        y += offset.y;

        float tx = x * scaleX;
        float ty = y * scaleY;

        tx = image.getTextureOffsetX() + (image.getTextureWidth() * tx);
        ty = image.getTextureOffsetY() + (image.getTextureHeight() * ty);

        GL.glTexCoord2f(tx, ty);

        return new float[] {offset.x + x,offset.y + y};
    });
    
    if (t == null) {
        TextureImpl.bindNone();
    } else {
        t.bind();
    }
}
 
开发者ID:FOShameDotOrg,项目名称:fuzzy-octo-shame,代码行数:44,代码来源:ShapeRenderer.java


注:本文中的org.newdawn.slick.ShapeFill类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。