]> git.proxmox.com Git - sencha-touch.git/blob - src/src/draw/sprite/Circle.js
import Sencha Touch 2.4.2 source
[sencha-touch.git] / src / src / draw / sprite / Circle.js
1 /**
2 * @class Ext.draw.sprite.Circle
3 * @extends Ext.draw.sprite.Path
4 *
5 * A sprite that represents a circle.
6 *
7 * @example preview miniphone
8 * new Ext.draw.Component({
9 * fullscreen: true,
10 * items: [{
11 * type: 'circle',
12 * cx: 100,
13 * cy: 100,
14 * r: 25,
15 * fillStyle: 'blue'
16 * }]
17 * });
18 *
19 */
20 Ext.define("Ext.draw.sprite.Circle", {
21 extend: "Ext.draw.sprite.Path",
22 alias: 'sprite.circle',
23 type: 'circle',
24 inheritableStatics: {
25 def: {
26 processors: {
27 /**
28 * @cfg {Number} [cx=0] The center coordinate of the sprite on the x-axis.
29 */
30 cx: "number",
31
32 /**
33 * @cfg {Number} [cy=0] The center coordinate of the sprite on the y-axis.
34 */
35 cy: "number",
36
37 /**
38 * @cfg {Number} [r=0] The radius of the sprite.
39 */
40 r: "number"
41 },
42 aliases: {
43 radius: "r",
44 x: "cx",
45 y: "cy",
46 centerX: "cx",
47 centerY: "cy"
48 },
49 defaults: {
50 cx: 0,
51 cy: 0,
52 r: 0
53 },
54 dirtyTriggers: {
55 cx: 'path',
56 cy: 'path',
57 r: 'path'
58 }
59 }
60 },
61
62 updatePlainBBox: function (plain) {
63 var attr = this.attr,
64 cx = attr.cx,
65 cy = attr.cy,
66 r = attr.r;
67 plain.x = cx - r;
68 plain.y = cy - r;
69 plain.width = r + r;
70 plain.height = r + r;
71 },
72
73 updateTransformedBBox: function (transform) {
74 var attr = this.attr,
75 cx = attr.cx,
76 cy = attr.cy,
77 r = attr.r,
78 matrix = attr.matrix,
79 scalesX = matrix.getScaleX(),
80 scalesY = matrix.getScaleY(),
81 w, h;
82 w = scalesX * r;
83 h = scalesY * r;
84 transform.x = matrix.x(cx, cy) - w;
85 transform.y = matrix.y(cx, cy) - h;
86 transform.width = w + w;
87 transform.height = h + h;
88 },
89
90 updatePath: function (path, attr) {
91 path.arc(attr.cx, attr.cy, attr.r, 0, Math.PI * 2, false);
92 }
93 });