Mercurial > projects > dwt-mac
comparison dwt/graphics/Transform.d @ 46:cfa563df4fdd
Updated Widget and Display to 3.514
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 05 Dec 2008 16:00:41 +0100 |
parents | d8635bb48c7c |
children |
comparison
equal
deleted
inserted
replaced
45:d8635bb48c7c | 46:cfa563df4fdd |
---|---|
189 public void getElements(float[] elements) { | 189 public void getElements(float[] elements) { |
190 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 190 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
191 if (elements is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 191 if (elements is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
192 if (elements.length < 6) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | 192 if (elements.length < 6) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
193 NSAutoreleasePool pool = null; | 193 NSAutoreleasePool pool = null; |
194 if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); | 194 if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); |
195 try { | 195 try { |
196 NSAffineTransformStruct struct_ = handle.transformStruct(); | 196 NSAffineTransformStruct struct_ = handle.transformStruct(); |
197 elements[0] = (float)/*64*/struct_.m11; | 197 elements[0] = cast(float)/*64*/struct_.m11; |
198 elements[1] = (float)/*64*/struct_.m12; | 198 elements[1] = cast(float)/*64*/struct_.m12; |
199 elements[2] = (float)/*64*/struct_.m21; | 199 elements[2] = cast(float)/*64*/struct_.m21; |
200 elements[3] = (float)/*64*/struct_.m22; | 200 elements[3] = cast(float)/*64*/struct_.m22; |
201 elements[4] = (float)/*64*/struct_.tX; | 201 elements[4] = cast(float)/*64*/struct_.tX; |
202 elements[5] = (float)/*64*/struct_.tY; | 202 elements[5] = cast(float)/*64*/struct_.tY; |
203 } finally { | 203 } finally { |
204 if (pool !is null) pool.release(); | 204 if (pool !is null) pool.release(); |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
220 NSAutoreleasePool pool = null; | 220 NSAutoreleasePool pool = null; |
221 try { | 221 try { |
222 NSAffineTransformStruct struct_ = NSAffineTransformStruct(); | 222 NSAffineTransformStruct struct_ = NSAffineTransformStruct(); |
223 struct_.m11 = 1; | 223 struct_.m11 = 1; |
224 struct_.m22 = 1; | 224 struct_.m22 = 1; |
225 handle.setTransformStruct(structt); | 225 handle.setTransformStruct(struct_); |
226 } finally { | 226 } finally { |
227 if (pool !is null) pool.release(); | 227 if (pool !is null) pool.release(); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
275 public bool isIdentity() { | 275 public bool isIdentity() { |
276 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 276 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
277 NSAutoreleasePool pool = null; | 277 NSAutoreleasePool pool = null; |
278 if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); | 278 if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); |
279 try { | 279 try { |
280 NSAffineTransformStruct struct = handle.transformStruct(); | 280 NSAffineTransformStruct struct_ = handle.transformStruct(); |
281 return struct.m11 is 1 && struct.m12 is 0 && struct.m21 is 0 && struct.m22 is 1 && struct.tX is 0 && struct.tY is 0; | 281 return struct_.m11 is 1 && struct_.m12 is 0 && struct_.m21 is 0 && struct_.m22 is 1 && struct_.tX is 0 && struct_.tY is 0; |
282 } finally { | 282 } finally { |
283 if (pool !is null) pool.release(); | 283 if (pool !is null) pool.release(); |
284 } | 284 } |
285 } | 285 } |
286 | 286 |
302 public void multiply(Transform matrix) { | 302 public void multiply(Transform matrix) { |
303 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 303 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
304 if (matrix is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 304 if (matrix is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
305 if (matrix.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | 305 if (matrix.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
306 NSAutoreleasePool pool = null; | 306 NSAutoreleasePool pool = null; |
307 if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); | 307 if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); |
308 try { | 308 try { |
309 handle.prependTransform(matrix.handle); | 309 handle.prependTransform(matrix.handle); |
310 } finally { | 310 } finally { |
311 if (pool !is null) pool.release(); | 311 if (pool !is null) pool.release(); |
312 } | 312 } |
326 * </ul> | 326 * </ul> |
327 */ | 327 */ |
328 public void rotate(float angle) { | 328 public void rotate(float angle) { |
329 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 329 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
330 NSAutoreleasePool pool = null; | 330 NSAutoreleasePool pool = null; |
331 if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); | 331 if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); |
332 try { | 332 try { |
333 handle.rotateByDegrees(angle); | 333 handle.rotateByDegrees(angle); |
334 } finally { | 334 } finally { |
335 if (pool !is null) pool.release(); | 335 if (pool !is null) pool.release(); |
336 } | 336 } |
348 * </ul> | 348 * </ul> |
349 */ | 349 */ |
350 public void scale(float scaleX, float scaleY) { | 350 public void scale(float scaleX, float scaleY) { |
351 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 351 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
352 NSAutoreleasePool pool = null; | 352 NSAutoreleasePool pool = null; |
353 if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); | 353 if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); |
354 try { | 354 try { |
355 handle.scaleXBy(scaleX, scaleY); | 355 handle.scaleXBy(scaleX, scaleY); |
356 } finally { | 356 } finally { |
357 if (pool !is null) pool.release(); | 357 if (pool !is null) pool.release(); |
358 } | 358 } |
446 size_t length = pointArray.length / 2; | 446 size_t length = pointArray.length / 2; |
447 for (size_t i = 0, j = 0; i < length; i++, j += 2) { | 447 for (size_t i = 0, j = 0; i < length; i++, j += 2) { |
448 point.x = pointArray[j]; | 448 point.x = pointArray[j]; |
449 point.y = pointArray[j + 1]; | 449 point.y = pointArray[j + 1]; |
450 point = handle.transformPoint(point); | 450 point = handle.transformPoint(point); |
451 pointArray[j] = (float)/*64*/point.x; | 451 pointArray[j] = cast(float)/*64*/point.x; |
452 pointArray[j + 1] = (float)/*64*/point.y; | 452 pointArray[j + 1] = cast(float)/*64*/point.y; |
453 } | 453 } |
454 } finally { | 454 } finally { |
455 if (pool !is null) pool.release(); | 455 if (pool !is null) pool.release(); |
456 } | 456 } |
457 } | 457 } |
468 * </ul> | 468 * </ul> |
469 */ | 469 */ |
470 public void translate(float offsetX, float offsetY) { | 470 public void translate(float offsetX, float offsetY) { |
471 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 471 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
472 NSAutoreleasePool pool = null; | 472 NSAutoreleasePool pool = null; |
473 if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); | 473 if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); |
474 try { | 474 try { |
475 handle.translateXBy(offsetX, offsetY); | 475 handle.translateXBy(offsetX, offsetY); |
476 } finally { | 476 } finally { |
477 if (pool !is null) pool.release(); | 477 if (pool !is null) pool.release(); |
478 } | 478 } |