public AsSubTexture(AsTexture parentTexture, AsRectangle region, bool ownsParent) { mParent = parentTexture; mOwnsParent = ownsParent; if(region == null) { setClipping(new AsRectangle(0, 0, 1, 1)); } else { setClipping(new AsRectangle(region.x / parentTexture.getWidth(), region.y / parentTexture.getHeight(), region.width / parentTexture.getWidth(), region.height / parentTexture.getHeight())); } }
public AsImage(AsTexture texture) : base(texture.getFrame() != null ? texture.getFrame().width : texture.getWidth(), texture.getFrame() != null ? texture.getFrame().height : texture.getHeight(), 0xffffff, texture.getPremultipliedAlpha()) { bool pma = texture.getPremultipliedAlpha(); mVertexData.setTexCoords(0, 0.0f, 0.0f); mVertexData.setTexCoords(1, 1.0f, 0.0f); mVertexData.setTexCoords(2, 0.0f, 1.0f); mVertexData.setTexCoords(3, 1.0f, 1.0f); mTexture = texture; mSmoothing = AsTextureSmoothing.BILINEAR; mVertexDataCache = new AsVertexData(4, pma); mVertexDataCacheInvalid = true; }
public AsTouchMarker() { mCenter = new AsPoint(); mTexture = createTexture(); int i = 0; for (; i < 2; ++i) { AsImage marker = new AsImage(mTexture); marker.setPivotX(mTexture.getWidth() / 2); marker.setPivotY(mTexture.getHeight() / 2); marker.setTouchable(false); addChild(marker); } }
public virtual void drawBundled(AsDrawingBlockCallback drawingBlock, int antiAliasing) { float scale = mActiveTexture.getScale(); AsContext3D context = AsStarling.getContext(); if (context == null) { throw new AsMissingContextError(); } sScissorRect.setTo(0, 0, mActiveTexture.getWidth() * scale, mActiveTexture.getHeight() * scale); context.setScissorRectangle(sScissorRect); if (getIsPersistent()) { AsTexture tmpTexture = mActiveTexture; mActiveTexture = mBufferTexture; mBufferTexture = tmpTexture; mHelperImage.setTexture(mBufferTexture); } mSupport.setRenderTarget(mActiveTexture); mSupport.clear(); if (getIsPersistent() && mBufferReady) { mHelperImage.render(mSupport, 1.0f); } else { mBufferReady = true; } try { mDrawing = true; if (drawingBlock != null) { drawingBlock(); } } finally { mDrawing = false; mSupport.finishQuadBatch(); mSupport.nextFrame(); mSupport.setRenderTarget(null); context.setScissorRectangle(null); } }
public AsButton(AsTexture upState, String text, AsTexture downState) { if(upState == null) { throw new AsArgumentError("Texture cannot be null"); } mUpState = upState; mDownState = downState != null ? downState : upState; mBackground = new AsImage(upState); mScaleWhenDown = downState != null ? 1.0f : 0.9f; mAlphaWhenDisabled = 0.5f; mEnabled = true; mIsDown = false; mUseHandCursor = true; mTextBounds = new AsRectangle(0, 0, upState.getWidth(), upState.getHeight()); mContents = new AsSprite(); mContents.addChild(mBackground); addChild(mContents); addEventListener(AsTouchEvent.TOUCH, onTouch); if(text.Length != 0) { this.setText(text); } }
protected override void activate(int pass, AsContext3D context, AsTexture texture) { updateParameters(pass, (int)(texture.getWidth() * texture.getScale()), (int)(texture.getHeight() * texture.getScale())); context.setProgramConstantsFromVector(AsContext3DProgramType.VERTEX, 4, mOffsets); context.setProgramConstantsFromVector(AsContext3DProgramType.FRAGMENT, 0, mWeights); if(mUniformColor && pass == getNumPasses() - 1) { context.setProgramConstantsFromVector(AsContext3DProgramType.FRAGMENT, 1, mColor); context.setProgram(mTintedProgram); } else { context.setProgram(mNormalProgram); } }
public AsSubTexture(AsTexture parentTexture, AsRectangle region, bool ownsParent) { mParent = parentTexture; mOwnsParent = ownsParent; if (region == null) { setClipping(new AsRectangle(0, 0, 1, 1)); } else { setClipping(new AsRectangle(region.x / parentTexture.getWidth(), region.y / parentTexture.getHeight(), region.width / parentTexture.getWidth(), region.height / parentTexture.getHeight())); } }
public override float getHeight() { return(mParent.getHeight() * mClipping.height); }