client/js/renderer/scene.js
changeset 398 57f8d344fde9
parent 396 b51c25ef4292
child 403 96781c1a8bbe
equal deleted inserted replaced
397:5617e706ba09 398:57f8d344fde9
   552                 }
   552                 }
   553             }
   553             }
   554         },
   554         },
   555         drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
   555         drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
   556             var _options = this.renkan.options,
   556             var _options = this.renkan.options,
   557             _startRads = _startAngle * Math.PI / 180,
   557                 _startRads = _startAngle * Math.PI / 180,
   558             _endRads = _endAngle * Math.PI / 180,
   558                 _endRads = _endAngle * Math.PI / 180,
   559             _img = this.icon_cache[_imgname],
   559                 _img = this.icon_cache[_imgname],
   560             _startdx = - Math.sin(_startRads),
   560                 _startdx = - Math.sin(_startRads),
   561             _startdy = Math.cos(_startRads),
   561                 _startdy = Math.cos(_startRads),
   562             _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,
   562                 _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,
   563             _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,
   563                 _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,
   564             _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,
   564                 _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,
   565             _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,
   565                 _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,
   566             _enddx = - Math.sin(_endRads),
   566                 _enddx = - Math.sin(_endRads),
   567             _enddy = Math.cos(_endRads),
   567                 _enddy = Math.cos(_endRads),
   568             _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,
   568                 _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,
   569             _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,
   569                 _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,
   570             _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,
   570                 _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,
   571             _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,
   571                 _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,
   572             _centerR = (_inR + _outR) / 2,
   572                 _centerR = (_inR + _outR) / 2,
   573             _centerRads = (_startRads + _endRads) / 2,
   573                 _centerRads = (_startRads + _endRads) / 2,
   574             _centerX = Math.cos(_centerRads) * _centerR,
   574                 _centerX = Math.cos(_centerRads) * _centerR,
   575             _centerY = Math.sin(_centerRads) * _centerR,
   575                 _centerY = Math.sin(_centerRads) * _centerR,
   576             _centerXIn = Math.cos(_centerRads) * _inR,
   576                 _centerXIn = Math.cos(_centerRads) * _inR,
   577             _centerXOut = Math.cos(_centerRads) * _outR,
   577                 _centerXOut = Math.cos(_centerRads) * _outR,
   578             _centerYIn = Math.sin(_centerRads) * _inR,
   578                 _centerYIn = Math.sin(_centerRads) * _inR,
   579             _centerYOut = Math.sin(_centerRads) * _outR,
   579                 _centerYOut = Math.sin(_centerRads) * _outR,
   580             _textX = Math.cos(_centerRads) * (_outR + 3),
   580                 _textX = Math.cos(_centerRads) * (_outR + 3),
   581             _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;
   581                 _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;
   582             this.buttons_layer.activate();
   582             this.buttons_layer.activate();
   583             var _path = new paper.Path();
   583             var _path = new paper.Path();
   584             _path.add([_startXIn, _startYIn]);
   584             _path.add([_startXIn, _startYIn]);
   585             _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]);
   585             _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]);
   586             _path.lineTo([_endXOut,  _endYOut]);
   586             _path.lineTo([_endXOut,  _endYOut]);
   601             } else {
   601             } else {
   602                 _text.paragraphStyle.justification = 'center';
   602                 _text.paragraphStyle.justification = 'center';
   603             }
   603             }
   604             _text.visible = false;
   604             _text.visible = false;
   605             var _visible = false,
   605             var _visible = false,
   606             _restPos = new paper.Point(-200, -200),
   606                 _restPos = new paper.Point(-200, -200),
   607             _grp = new paper.Group([_path, _text]),
   607                 _grp = new paper.Group([_path, _text]),
   608             _delta = _grp.position,
   608                 //_grp = new paper.Group([_path]),
   609             _imgdelta = new paper.Point([_centerX, _centerY]),
   609                 _delta = _grp.position,
   610             _currentPos = new paper.Point(0,0);
   610                 _imgdelta = new paper.Point([_centerX, _centerY]),
       
   611                 _currentPos = new paper.Point(0,0);
   611             _text.content = _caption;
   612             _text.content = _caption;
       
   613             // set group pivot to not depend on text visibility that changes the group bounding box.
       
   614             _grp.pivot = _grp.bounds.center;
   612             _grp.visible = false;
   615             _grp.visible = false;
   613             _grp.position = _restPos;
   616             _grp.position = _restPos;
   614             var _res = {
   617             var _res = {
   615                     show: function() {
   618                     show: function() {
   616                         _visible = true;
   619                         _visible = true;