ScaleBitmap : New version by Didier Brun

by 老姜 2011.4.21 18:31

原文地址:http://www.bytearray.org/?p=1206

Let me introduce the new version of ScaleBitmap :

ScaleBitmap V2 Illustration

I have totally rewritten ScaleBitmap to suit my needs :

  • Better usage of memory : no more creation of BitmapData instance (possibility to swap BitmapData)
  • Outer drawing capability
  • ScaleBitmapSprite

    The outer drawing & ScaleBitmapSprite allows you to :

  • Easily deal with shadow, glow, overlapping icon effects
  • Use real size & position to align or place your elements

    Usage 1 : ScaleBitmap

    1.ScaleBitmap.draw(
    2.bitmap : BitmapData, // the bitmap source
    3.graphic:Graphics, // the destination graphic
    4.width:Number, // width (defined by outer rectangle if not null)
    5.height:Number, // height (defined by outer rectangle if not null)
    6.inner : Rectangle, // inner rectangle for scale 9
    7.outer : Rectangle=null // outer rectangle : visual size reference
    8.):void

    If outer is not null, ScaleBitmap use a negative offset for drawing (according to outer properties)
    If outer is null, ScaleBitmap works as a classic Scale9 grid drawer

    Usage 2 : ScaleBitmapSprite

    01.ScaleBitmapSprite(
    02.bitmap : BitmapData, // the bitmap source
    03.inner : Rectangle, // inner rectangle for scale 9
    04.outer : Rectangle=null) // outer rectangle : visual size reference
    05.  
    06.var s:ScaleBitmapSprite=new ScaleBitmapSprite(mySkin, new Rectangle(20,20,80,20), new Rectangle(15,15,90,30));
    07.addChild(s);
    08.s.width=80;
    09.s.height=40;</a>

    ScaleBitmapSprite override public size setter & getter : you can move & resize a ScaleBitmapSprite object without taking care of bitmap outer drawing.

    Simple MyButton class using ScaleBitmapSprite (click the button) :


    Sources FCS4 [ require Eaze to compile]

    Download ScaleBitmap & ScaleBitmapSprite :
    Repository : http://gist.github.com/264250

    Some of you prefer gist, so as possible, I will share my new projects via gist.

    Hope this class help & merry Xmas to bytearray readers.

    [EDIT 2010-05-18]

    A new version 1.1 is available !

    Jerôme Decoster, a talented french developer have made a lot of improvements in this new version :

    • smooth support
    • invalidation for ScaleBitmapSprite
    • code optimization
    • inner drawing correction

    So many thanks to you Jerôme :)

    Repository : http://gist.github.com/264250

  • Tags:

    Flash技术

    Add comment




      Country flag
    biuquote
    • Comment
    • Preview
    微笑得意调皮害羞酷大笑惊讶发呆喜欢可怜尴尬闭嘴噘嘴皱眉伤心抓狂呕吐坏笑漫骂发怒
    Loading


    关于博主

    我很想写点什么来让你了解我...

    归档

    页面

    最近的文章

    声明

    本博所有网友评论不代表本博立场,版权归其作者所有。

    © Copyright 2011