MCPcopy Index your code
hub / github.com/jabbany/CommentCoreLibrary / BitmapData

Class BitmapData

src/scripting/api/Display/Bitmap.ts:109–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107 * @author Jim Chen
108 */
109 export class BitmapData {
110 private _id:string;
111 private _rect:Rectangle;
112 private _locked:boolean = false;
113 private _dirtyArea:DirtyArea;
114 private _transparent:boolean;
115 private _fillColor:number;
116 private _byteArray:Array<number>;
117
118 constructor(width:number,
119 height:number,
120 transparent:boolean = true,
121 fillColor:number = 0xffffffff,
122 id:string = Runtime.generateId()) {
123
124 this._id = id;
125 this._rect = new Rectangle(0, 0, width, height);
126 this._transparent = transparent;
127 this._fillColor = fillColor;
128 this._fill();
129 }
130
131 private _fill():void {
132 this._byteArray = [];
133 for (var i = 0; i < this._rect.width * this._rect.height; i++) {
134 this._byteArray.push(this._fillColor);
135 }
136 }
137
138 private _updateBox(changeRect:Rectangle = null):void {
139 if (this._dirtyArea.isEmpty()) {
140 // Don't update anything if nothing was changed
141 return;
142 }
143 if (this._locked) {
144 // Don't send updates if this is locked
145 return;
146 }
147 var change:Rectangle = changeRect === null ? this._dirtyArea.asRect() :
148 changeRect;
149
150 // Make sure we're not out-of-bounds
151 if (!this._rect.containsRect(change)) {
152 __trace('BitmapData._updateBox box ' + change.toString() +
153 ' out of bonunds ' + this._rect.toString(), 'err');
154 throw new Error('Rectangle provided was not within image bounds.');
155 }
156 // Extract the values
157 var region:Array<number> = [];
158 for (var i = 0; i < change.height; i++) {
159 for (var j = 0; j < change.width; j++) {
160 region.push(this._byteArray[(change.y + i) * this._rect.width +
161 change.x + j]);
162 }
163 }
164 this._call('updateBox', {
165 'box': change.serialize(),
166 'values': region

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected