public static void uploadBitmapData(bc.flash.display3D.textures.AsTexture nativeTexture, AsBitmapData data, bool generateMipmaps) { nativeTexture.uploadFromBitmapData(data); if (generateMipmaps && data.getWidth() > 1 && data.getHeight() > 1) { int currentWidth = data.getWidth() >> 1; int currentHeight = data.getHeight() >> 1; int level = 1; AsBitmapData canvas = new AsBitmapData(currentWidth, currentHeight, true, 0); AsMatrix transform = new AsMatrix(.5f, 0, 0, .5f); AsRectangle bounds = new AsRectangle(); while (currentWidth >= 1 || currentHeight >= 1) { bounds.width = currentWidth; bounds.height = currentHeight; canvas.fillRect(bounds, (uint)(0)); canvas.draw(data, transform, null, null, null, true); nativeTexture.uploadFromBitmapData(canvas, (uint)(level++)); transform.scale(0.5f, 0.5f); currentWidth = currentWidth >> 1; currentHeight = currentHeight >> 1; } canvas.dispose(); } }
private void createComposedContents() { if (mImage != null) { mImage.removeFromParent(true); mImage = null; } if (mQuadBatch == null) { mQuadBatch = new AsQuadBatch(); mQuadBatch.setTouchable(false); addChild(mQuadBatch); } else { mQuadBatch.reset(); } AsBitmapFont bitmapFont = (AsBitmapFont)(getBitmapFonts()[mFontName]); if (bitmapFont == null) { throw new AsError("Bitmap font not registered: " + mFontName); } bitmapFont.fillQuadBatch(mQuadBatch, mHitArea.getWidth(), mHitArea.getHeight(), mText, mFontSize, mColor, mHAlign, mVAlign, mAutoScale, mKerning); mTextBounds = null; }
public static AsTexture fromTexture(AsTexture texture, AsRectangle region, AsRectangle frame) { AsTexture subTexture = new AsSubTexture(texture, region); subTexture.mFrame = frame; return(subTexture); }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if (resultRect == null) { resultRect = new AsRectangle(); } AsMatrix transformationMatrix = targetSpace == this ? null : getTransformationMatrix(targetSpace, sHelperMatrix); return(mVertexData.getBounds(transformationMatrix, 0, mNumQuads * 4, resultRect)); }
private void parseFontXml(AsXML fontXml) { float scale = mTexture.getScale(); AsRectangle frame = mTexture.getFrame(); mName = fontXml.elements("info").attribute("face"); mSize = AsGlobal.parseFloat(fontXml.elements("info").attribute("size")) / scale; mLineHeight = AsGlobal.parseFloat(fontXml.elements("common").attribute("lineHeight")) / scale; mBaseline = AsGlobal.parseFloat(fontXml.elements("common").attribute("base")) / scale; if (fontXml.elements("info").attribute("smooth").ToString() == "0") { setSmoothing(AsTextureSmoothing.NONE); } if (mSize <= 0) { AsGlobal.trace("[Starling] Warning: invalid font size in '" + mName + "' font."); mSize = mSize == 0.0f ? 16.0f : mSize * -1.0f; } AsXMLList __charElements_ = fontXml.elements("chars").elements("_char"); if (__charElements_ != null) { foreach (AsXML charElement in __charElements_) { int id = (int)(AsGlobal.parseInt(charElement.attribute("id"))); float xOffset = AsGlobal.parseFloat(charElement.attribute("xoffset")) / scale; float yOffset = AsGlobal.parseFloat(charElement.attribute("yoffset")) / scale; float xAdvance = AsGlobal.parseFloat(charElement.attribute("xadvance")) / scale; AsRectangle region = new AsRectangle(); region.x = AsGlobal.parseFloat(charElement.attribute("x")) / scale + frame.x; region.y = AsGlobal.parseFloat(charElement.attribute("y")) / scale + frame.y; region.width = AsGlobal.parseFloat(charElement.attribute("width")) / scale; region.height = AsGlobal.parseFloat(charElement.attribute("height")) / scale; AsTexture texture = AsTexture.fromTexture(mTexture, region); AsBitmapChar bitmapChar = new AsBitmapChar(id, texture, xOffset, yOffset, xAdvance); addChar(id, bitmapChar); } } AsXMLList __kerningElements_ = fontXml.elements("kernings").elements("kerning"); if (__kerningElements_ != null) { foreach (AsXML kerningElement in __kerningElements_) { int first = (int)(AsGlobal.parseInt(kerningElement.attribute("first"))); int second = (int)(AsGlobal.parseInt(kerningElement.attribute("second"))); float amount = AsGlobal.parseFloat(kerningElement.attribute("amount")) / scale; if (mChars.containsKey(second)) { getChar(second).addKerning(first, amount); } } } }
public virtual AsRectangle getTextBounds() { if (mRequiresRedraw) { redrawContents(); } if (mTextBounds == null) { mTextBounds = mQuadBatch.getBounds(mQuadBatch); } return(mTextBounds.clone()); }
public virtual void readjustSize() { AsRectangle frame = getTexture().getFrame(); float width = frame != null ? frame.width : getTexture().getWidth(); float height = frame != null ? frame.height : getTexture().getHeight(); mVertexData.setPosition(0, 0.0f, 0.0f); mVertexData.setPosition(1, width, 0.0f); mVertexData.setPosition(2, 0.0f, height); mVertexData.setPosition(3, width, height); onVertexDataChanged(); }
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 virtual AsTexture getTexture(String name) { AsRectangle region = (AsRectangle)(mTextureRegions[name]); if (region == null) { return(null); } else { return(AsTexture.fromTexture(mAtlasTexture, region, (AsRectangle)(mTextureFrames[name]))); } }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if ((resultRect == null)) { resultRect = new AsRectangle(); } if ((targetSpace == this)) { resultRect.x = getX(); resultRect.y = getY(); resultRect.width = mBitmapData.getWidth(); resultRect.height = mBitmapData.getHeight(); return(resultRect); } float minX = AsMathHelper.MAX_NUMBER; float maxX = -AsMathHelper.MAX_NUMBER; float minY = AsMathHelper.MAX_NUMBER; float maxY = -AsMathHelper.MAX_NUMBER; getTransformationMatrix(targetSpace, sHelperMatrix); sPosition.x = getX(); sPosition.y = getY(); AsGlobal.transformCoords(sHelperMatrix, sPosition.x, sPosition.y, sHelperPoint); minX = (((minX < sHelperPoint.x)) ? (minX) : (sHelperPoint.x)); maxX = (((maxX > sHelperPoint.x)) ? (maxX) : (sHelperPoint.x)); minY = (((minY < sHelperPoint.y)) ? (minY) : (sHelperPoint.y)); maxY = (((maxY > sHelperPoint.y)) ? (maxY) : (sHelperPoint.y)); sPosition.x = (sPosition.x + getBitmapData().getWidth()); AsGlobal.transformCoords(sHelperMatrix, sPosition.x, sPosition.y, sHelperPoint); minX = (((minX < sHelperPoint.x)) ? (minX) : (sHelperPoint.x)); maxX = (((maxX > sHelperPoint.x)) ? (maxX) : (sHelperPoint.x)); minY = (((minY < sHelperPoint.y)) ? (minY) : (sHelperPoint.y)); maxY = (((maxY > sHelperPoint.y)) ? (maxY) : (sHelperPoint.y)); sPosition.y = (sPosition.y + getBitmapData().getHeight()); AsGlobal.transformCoords(sHelperMatrix, sPosition.x, sPosition.y, sHelperPoint); minX = (((minX < sHelperPoint.x)) ? (minX) : (sHelperPoint.x)); maxX = (((maxX > sHelperPoint.x)) ? (maxX) : (sHelperPoint.x)); minY = (((minY < sHelperPoint.y)) ? (minY) : (sHelperPoint.y)); maxY = (((maxY > sHelperPoint.y)) ? (maxY) : (sHelperPoint.y)); sPosition.x = getX(); AsGlobal.transformCoords(sHelperMatrix, sPosition.x, sPosition.y, sHelperPoint); minX = (((minX < sHelperPoint.x)) ? (minX) : (sHelperPoint.x)); maxX = (((maxX > sHelperPoint.x)) ? (maxX) : (sHelperPoint.x)); minY = (((minY < sHelperPoint.y)) ? (minY) : (sHelperPoint.y)); maxY = (((maxY > sHelperPoint.y)) ? (maxY) : (sHelperPoint.y)); resultRect.x = minX; resultRect.y = minY; resultRect.width = (maxX - minX); resultRect.height = (maxY - minY); return(resultRect); }
private void updateBuffers(AsContext3D context, AsRectangle bounds) { mVertexData.setPosition(0, bounds.x, bounds.y); mVertexData.setPosition(1, bounds.getRight(), bounds.y); mVertexData.setPosition(2, bounds.x, bounds.getBottom()); mVertexData.setPosition(3, bounds.getRight(), bounds.getBottom()); if (mVertexBuffer == null) { mVertexBuffer = context.createVertexBuffer(4, AsVertexData.ELEMENTS_PER_VERTEX); mIndexBuffer = context.createIndexBuffer(6); mIndexBuffer.uploadFromVector(mIndexData, 0, 6); } mVertexBuffer.uploadFromVector(mVertexData.getRawData(), 0, 4); }
private void updateViewPort() { mViewPortClipped = mViewPort.intersection(new AsRectangle(0, 0, mNativeStage.getStageWidth(), mNativeStage.getStageHeight())); if (mShareContext) { return; } if (mContext != null && mContext.getDriverInfo() != "Disposed") { mContext.configureBackBuffer((int)(mViewPortClipped.width), (int)(mViewPortClipped.height), mAntiAliasing, false); } mStage3D.setX(mViewPortClipped.x); mStage3D.setY(mViewPortClipped.y); }
public virtual AsRectangle getBounds(AsMatrix transformationMatrix, int vertexID, int numVertices, AsRectangle resultRect) { if (resultRect == null) { resultRect = new AsRectangle(); } if (numVertices < 0 || vertexID + numVertices > mNumVertices) { numVertices = mNumVertices - vertexID; } float minX = AsNumber.MAX_VALUE; float maxX = -AsNumber.MAX_VALUE; float minY = AsNumber.MAX_VALUE; float maxY = -AsNumber.MAX_VALUE; int offset = getOffset(vertexID) + POSITION_OFFSET; float x = 0; float y = 0; int i = 0; if (transformationMatrix == null) { for (i = vertexID; i < numVertices; ++i) { x = mRawData[offset]; y = mRawData[(offset + 1)]; offset = offset + ELEMENTS_PER_VERTEX; minX = minX < x ? minX : x; maxX = maxX > x ? maxX : x; minY = minY < y ? minY : y; maxY = maxY > y ? maxY : y; } } else { for (i = vertexID; i < numVertices; ++i) { x = mRawData[offset]; y = mRawData[(offset + 1)]; offset = offset + ELEMENTS_PER_VERTEX; AsMatrixUtil.transformCoords(transformationMatrix, x, y, sHelperPoint); minX = minX < sHelperPoint.x ? minX : sHelperPoint.x; maxX = maxX > sHelperPoint.x ? maxX : sHelperPoint.x; minY = minY < sHelperPoint.y ? minY : sHelperPoint.y; maxY = maxY > sHelperPoint.y ? maxY : sHelperPoint.y; } } resultRect.setTo(minX, minY, maxX - minX, maxY - minY); return(resultRect); }
private void setClipping(AsRectangle _value) { mClipping = _value; mRootClipping = _value.clone(); AsSubTexture parentTexture = mParent as AsSubTexture; while (parentTexture != null) { AsRectangle parentClipping = parentTexture.mClipping; mRootClipping.x = parentClipping.x + mRootClipping.x * parentClipping.width; mRootClipping.y = parentClipping.y + mRootClipping.y * parentClipping.height; mRootClipping.width = mRootClipping.width * parentClipping.width; mRootClipping.height = mRootClipping.height * parentClipping.height; parentTexture = parentTexture.mParent as AsSubTexture; } }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if (resultRect == null) { resultRect = new AsRectangle(); } int childsCount = getNumChildren(); if (childsCount == 0) { getTransformationMatrix(targetSpace, sHelperMatrix); AsGlobal.transformCoords(sHelperMatrix, 0.0f, 0.0f, sHelperPoint); resultRect.x = sHelperPoint.x; resultRect.y = sHelperPoint.y; resultRect.width = resultRect.height = 0; return(resultRect); } else { if (childsCount == 1) { return(mChildren[0].getBounds(targetSpace, resultRect)); } else { float minX = AsMathHelper.MAX_NUMBER; float maxX = -AsMathHelper.MAX_NUMBER; float minY = AsMathHelper.MAX_NUMBER; float maxY = -AsMathHelper.MAX_NUMBER; int i = 0; for (; i < childsCount; ++i) { mChildren[i].getBounds(targetSpace, resultRect); minX = minX < resultRect.x ? minX : resultRect.x; maxX = maxX > resultRect.getRight() ? maxX : resultRect.getRight(); minY = minY < resultRect.y ? minY : resultRect.y; maxY = maxY > resultRect.getBottom() ? maxY : resultRect.getBottom(); } resultRect.x = minX; resultRect.y = minY; resultRect.width = maxX - minX; resultRect.height = maxY - minY; return(resultRect); } } }
private void calculateBounds(AsDisplayObject _object, AsStage stage, AsRectangle resultRect) { if (_object == stage || _object == AsStarling.getCurrent().getRoot()) { resultRect.setTo(0, 0, stage.getStageWidth(), stage.getStageHeight()); } else { _object.getBounds(stage, resultRect); } float deltaMargin = mResolution == 1.0f ? 0.0f : 1.0f / mResolution; resultRect.x = resultRect.x - mMarginX + deltaMargin; resultRect.y = resultRect.y - mMarginY + deltaMargin; resultRect.width = resultRect.width + 2 * (mMarginX + deltaMargin); resultRect.height = resultRect.height + 2 * (mMarginY + deltaMargin); resultRect.width = AsGlobal.getNextPowerOfTwo((int)(resultRect.width * mResolution)) / mResolution; resultRect.height = AsGlobal.getNextPowerOfTwo((int)(resultRect.height * mResolution)) / mResolution; }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if (resultRect == null) { resultRect = new AsRectangle(); } int numChildren = (int)(mChildren.getLength()); if (numChildren == 0) { getTransformationMatrix(targetSpace, sHelperMatrix); AsMatrixUtil.transformCoords(sHelperMatrix, 0.0f, 0.0f, sHelperPoint); resultRect.setTo(sHelperPoint.x, sHelperPoint.y, 0, 0); return(resultRect); } else { if (numChildren == 1) { return(mChildren[0].getBounds(targetSpace, resultRect)); } else { float minX = AsNumber.MAX_VALUE; float maxX = -AsNumber.MAX_VALUE; float minY = AsNumber.MAX_VALUE; float maxY = -AsNumber.MAX_VALUE; int i = 0; for (; i < numChildren; ++i) { mChildren[i].getBounds(targetSpace, resultRect); minX = minX < resultRect.x ? minX : resultRect.x; maxX = maxX > resultRect.getRight() ? maxX : resultRect.getRight(); minY = minY < resultRect.y ? minY : resultRect.y; maxY = maxY > resultRect.getBottom() ? maxY : resultRect.getBottom(); } resultRect.setTo(minX, minY, maxX - minX, maxY - minY); return(resultRect); } } }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if (resultRect == null) { resultRect = new AsRectangle(); } if (targetSpace == this) { mVertexData.getPosition(3, sHelperPoint); resultRect.setTo(0.0f, 0.0f, sHelperPoint.x, sHelperPoint.y); } else { if (targetSpace == getParent() && getRotation() == 0.0f) { float scaleX = this.getScaleX(); float scaleY = this.getScaleY(); mVertexData.getPosition(3, sHelperPoint); resultRect.setTo(getX() - getPivotX() * scaleX, getY() - getPivotY() * scaleY, sHelperPoint.x * scaleX, sHelperPoint.y * scaleY); if (scaleX < 0) { resultRect.width = resultRect.width * -1; resultRect.x = resultRect.x - resultRect.width; } if (scaleY < 0) { resultRect.height = resultRect.height * -1; resultRect.y = resultRect.y - resultRect.height; } } else { getTransformationMatrix(targetSpace, sHelperMatrix); mVertexData.getBounds(sHelperMatrix, 0, 4, resultRect); } } return(resultRect); }
private void onTouch(AsTouchEvent _event) { AsMouse.setCursor(mUseHandCursor && mEnabled && _event.interactsWith(this) ? AsMouseCursor.BUTTON : AsMouseCursor.AUTO); AsTouch touch = _event.getTouch(this); if (!mEnabled || touch == null) { return; } if (touch.getPhase() == AsTouchPhase.BEGAN && !mIsDown) { mBackground.setTexture(mDownState); mContents.setScaleX(mContents.setScaleY(mScaleWhenDown)); mContents.setX((1.0f - mScaleWhenDown) / 2.0f * mBackground.getWidth()); mContents.setY((1.0f - mScaleWhenDown) / 2.0f * mBackground.getHeight()); mIsDown = true; } else { if (touch.getPhase() == AsTouchPhase.MOVED && mIsDown) { AsRectangle buttonRect = getBounds(getStage()); if (touch.getGlobalX() < buttonRect.x - MAX_DRAG_DIST || touch.getGlobalY() < buttonRect.y - MAX_DRAG_DIST || touch.getGlobalX() > buttonRect.x + buttonRect.width + MAX_DRAG_DIST || touch.getGlobalY() > buttonRect.y + buttonRect.height + MAX_DRAG_DIST) { resetContents(); } } else { if (touch.getPhase() == AsTouchPhase.ENDED && mIsDown) { resetContents(); dispatchEventWith(AsEvent.TRIGGERED, true); } } } }
protected virtual void parseAtlasXml(AsXML atlasXml) { float scale = mAtlasTexture.getScale(); AsSubTexture __subTextures_ = atlasXml.SubTexture; if (__subTextures_ != null) { foreach (AsXML subTexture in __subTextures_) { String name = subTexture.attribute("name"); float x = AsGlobal.parseFloat(subTexture.attribute("x")) / scale; float y = AsGlobal.parseFloat(subTexture.attribute("y")) / scale; float width = AsGlobal.parseFloat(subTexture.attribute("width")) / scale; float height = AsGlobal.parseFloat(subTexture.attribute("height")) / scale; float frameX = AsGlobal.parseFloat(subTexture.attribute("frameX")) / scale; float frameY = AsGlobal.parseFloat(subTexture.attribute("frameY")) / scale; float frameWidth = AsGlobal.parseFloat(subTexture.attribute("frameWidth")) / scale; float frameHeight = AsGlobal.parseFloat(subTexture.attribute("frameHeight")) / scale; AsRectangle region = new AsRectangle(x, y, width, height); AsRectangle frame = frameWidth > 0 && frameHeight > 0 ? new AsRectangle(frameX, frameY, frameWidth, frameHeight) : null; addRegion(name, region, frame); } } }
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); } }
public virtual void setScissorRectangle(AsRectangle rectangle) { throw new AsNotImplementedError(); }
public virtual AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { throw new AsAbstractMethodError("Method needs to be implemented in subclass"); }
public virtual void setScrollRect(AsRectangle _value) { mScrollRect = _value; }
public AsSubTexture(AsTexture parentTexture, AsRectangle region) : this(parentTexture, region, false) { }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { return(mHitArea.getBounds(targetSpace, resultRect)); }
public AsStarling(AsClass rootClass, bc.flash.display.AsStage stage, AsRectangle viewPort, AsStage3D stage3D, String renderMode, String profile) { if (stage == null) { throw new AsArgumentError("Stage must not be null"); } if (rootClass == null) { throw new AsArgumentError("Root class must not be null"); } if (viewPort == null) { viewPort = new AsRectangle(0, 0, stage.getStageWidth(), stage.getStageHeight()); } if (stage3D == null) { stage3D = stage.getStage3Ds()[0]; } makeCurrent(); mRootClass = rootClass; mViewPort = viewPort; mStage3D = stage3D; mStage = new AsStage(viewPort.width, viewPort.height, stage.getColor()); mNativeOverlay = new AsSprite(); mNativeStage = stage; mNativeStage.addChild(mNativeOverlay); mTouchProcessor = new AsTouchProcessor(mStage); mJuggler = new AsJuggler(); mAntiAliasing = 0; mSimulateMultitouch = false; mEnableErrorChecking = false; mLastFrameTimestamp = AsGlobal.getTimer() / 1000.0f; mPrograms = new AsDictionary(); mCustomData = new AsDictionary(); mSupport = new AsRenderSupport(); AsArray __touchEventTypes_ = getTouchEventTypes(); if (__touchEventTypes_ != null) { foreach (String touchEventType in __touchEventTypes_) { stage.addEventListener(touchEventType, onTouch, false, 0, true); } } stage.addEventListener(AsEvent.ENTER_FRAME, onEnterFrame, false, 0, true); stage.addEventListener(AsKeyboardEvent.KEY_DOWN, onKey, false, 0, true); stage.addEventListener(AsKeyboardEvent.KEY_UP, onKey, false, 0, true); stage.addEventListener(AsEvent.RESIZE, onResize, false, 0, true); if (mStage3D.getContext3D() != null && mStage3D.getContext3D().getDriverInfo() != "Disposed") { mShareContext = true; AsGlobal.setTimeout(initialize, 1); } else { mShareContext = false; mStage3D.addEventListener(AsEvent.CONTEXT3D_CREATE, onContextCreated, false, 1, true); mStage3D.addEventListener(AsErrorEvent.ERROR, onStage3DError, false, 1, true); try { mStage3D.requestContext3D(renderMode); } catch (AsError e) { showFatalError("Context3D error: " + e.message); } } }
private void createRenderedContents() { if (mQuadBatch != null) { mQuadBatch.removeFromParent(true); mQuadBatch = null; } float scale = AsStarling.getContentScaleFactor(); float width = mHitArea.getWidth() * scale; float height = mHitArea.getHeight() * scale; AsTextFormat textFormat = new AsTextFormat(mFontName, mFontSize * scale, mColor, mBold, mItalic, mUnderline, null, null, mHAlign); textFormat.setKerning(mKerning); sNativeTextField.setDefaultTextFormat(textFormat); sNativeTextField.setWidth(width); sNativeTextField.setHeight(height); sNativeTextField.setAntiAliasType(AsAntiAliasType.ADVANCED); sNativeTextField.setSelectable(false); sNativeTextField.setMultiline(true); sNativeTextField.setWordWrap(true); sNativeTextField.setText(mText); sNativeTextField.setEmbedFonts(true); sNativeTextField.setOwnProperty("filters", mNativeFilters); if (sNativeTextField.getTextWidth() == 0.0f || sNativeTextField.getTextHeight() == 0.0f) { sNativeTextField.setEmbedFonts(false); } if (mAutoScale) { autoScaleNativeTextField(sNativeTextField); } float textWidth = sNativeTextField.getTextWidth(); float textHeight = sNativeTextField.getTextHeight(); float xOffset = 0.0f; if (mHAlign == AsHAlign.LEFT) { xOffset = 2; } else { if (mHAlign == AsHAlign.CENTER) { xOffset = (width - textWidth) / 2.0f; } else { if (mHAlign == AsHAlign.RIGHT) { xOffset = width - textWidth - 2; } } } float yOffset = 0.0f; if (mVAlign == AsVAlign.TOP) { yOffset = 2; } else { if (mVAlign == AsVAlign.CENTER) { yOffset = (height - textHeight) / 2.0f; } else { if (mVAlign == AsVAlign.BOTTOM) { yOffset = height - textHeight - 2; } } } AsBitmapData bitmapData = new AsBitmapData(width, height, true, 0x0); bitmapData.draw(sNativeTextField, new AsMatrix(1, 0, 0, 1, 0, ((int)(yOffset)) - 2)); sNativeTextField.setText(""); if (mTextBounds == null) { mTextBounds = new AsRectangle(); } mTextBounds.setTo(xOffset / scale, yOffset / scale, textWidth / scale, textHeight / scale); AsTexture texture = AsTexture.fromBitmapData(bitmapData, false, false, scale); if (mImage == null) { mImage = new AsImage(texture); mImage.setTouchable(false); addChild(mImage); } else { mImage.getTexture().dispose(); mImage.setTexture(texture); mImage.readjustSize(); } }
public virtual void setViewPort(AsRectangle _value) { mViewPort = _value.clone(); updateViewPort(); }
public virtual void setFullScreenSourceRect(AsRectangle _value) { mFullScreenSourceRect = _value; }