$scope.toRadians = function (degrees)
{
return degrees * (Math.PI / 180);
}

$scope.toDegrees = function (radians)
{
return radians * 180 / Math.PI;
}

$scope.initCircle = function () {
//alert(document.body.clientHeight);
var w = document.body.clientWidth;
var h = document.body.clientHeight - 50;
var centerOriginx = w / 2 + 5;
var centerOriginy = h / 3 + 20;
var paper = Raphael('diagram', w, h);
$scope.paper = paper;
paper.text(60, 10, '技能信息').attr('font-size', 15);
//var paper = Raphael(10, 50, 320, 200);
// 在坐标(x = 50, y = 40)绘制半径为 10 的圆
var radius = 50;

if (document.body.clientHeight <= 480) {
//radius = 35;
}
var circle = paper.circle(centerOriginx, centerOriginy, radius);
// 给绘制的圆圈填充红色 (#f00)
circle.attr("fill", "#2f51ac");
// 设置画笔(stroke)的颜色为白色
circle.attr("stroke", "#fff").attr('stroke-width', 0);
//animate2();
var tag0 = '';
if ($scope.tags.length > 0 && $scope.tags[0])
tag0 = $scope.tags[0];
var textcenter = paper.text(centerOriginx, centerOriginy, tag0).attr({
font: "15px sans-serif"
});
circle_outer = paper.circle(centerOriginx, centerOriginy, radius + 10);
circle_outer.attr("stroke", "#3e58af");

var stcenter = paper.set();
stcenter.push(
circle,
circle_outer,
textcenter
);
animateCenter(stcenter);
//st.attr({fill: "red"});
// angle = self.options.dots ? (index * 360 / $slides.length) : parseInt($(slide).attr("data-degrees"), 10)
// , position =
// {
// top : -Math.cos(toRadians(angle)) * self.options.radius + containerSize.height / 2 - dotSize.height / 2
// , left : Math.sin(toRadians(angle)) * self.options.radius + containerSize.width / 2 - dotSize.width / 2
// }
var i = 1;
//var length = 7;
while (i < $scope.tags.length + 1) {
var color = '#67bacb';
switch (i) {
case 1:
color = '#e3423f';
break;
case 2:
color = '#f88500';
break;
case 3:
color = '#d9c93a';
break;
case 4:
color = '#009da1';
break;
case 5:
color = '#55c042';
break;
case 6:
color = '#283388';
break;
}
var r = radius;
var angle = i * 360 / $scope.tags.length;
var top = -Math.cos($scope.toRadians(angle)) * 110 + centerOriginy- 10 / 2;
var left = Math.sin($scope.toRadians(angle)) * 110 + centerOriginx - 10 / 2;
var c = paper.circle(left, top, radius - 10);
c.click(function () {
//s.animate({transform: t, stroke: c}, 2000, "bounce");
//this.animate({cx: this.attr('cx')}, this.attr('cx') + 20, "elastic");
//this.cx = 400;
}).touchstart(function () {
this.animate({"fill-opacity": .75}, 500);
}).touchend(function () {
this.animate({"fill-opacity": .4}, 500);
});

// 给绘制的圆圈填充红色 (#f00)
c.attr("fill", color).attr('stroke-width', 0);

//var _anim = Raphael.animation({50:{ "fill-opacity": .1} ,1000:{ "fill-opacity": .8} }, 2000);
//c.animate(_anim.repeat("Infinity"));

var _txt = paper.text(left, top, $scope.tags[i - 1]).attr({
font: "13px sans-serif", fill:'#ffffff'
});

var _set = paper.set();
_set.push(
c,
_txt
);
//animateCenter(_set);
++i;
}

var _y = h - 100;
var rect = paper.rect(0, _y, w, 90);
_y += 40;
rect.attr('fill','#2f51ab').attr( "stroke", "#3e58af");
var _txt = paper.text(150, _y, '个人说明:' + $scope.desc).attr({
font: "15px sans-serif", fill:'#ffffff'
});

function animateCenter(o) {
var ms = 4000;
var _r = 50;
if (document.body.clientHeight <= 480) {
_r = 35;
}
var anim = Raphael.animation({
50: {
r: _r,
//stroke: '#f00',
"fill-opacity": .95
},
100: {
r: 40,
//stroke: '#fff',
"fill-opacity": .4
},350: {
r: _r,
//stroke: '#f00',
"fill-opacity": 1
}
}, ms);

o.animate(anim.repeat("Infinity")); //Infinity为无限次
}

function animate2() {
var ms = 1000;
var easing = 'elastic';

stcenter.animate({
cx: centerOriginx + Math.random() * 120, //圆心x坐标
cy: centerOriginy + Math.random() * 100, //圆心y坐标
}, ms, easing, function(){
setTimeout(animate2, 1000);
});
}

function animate() {
var ms = 1000;
var easing = ['elastic', '', 'bounce', 'ease-in-out'][Math.round(Math.random() * 3)];

circle.animate({
cx: 50 + Math.random() * 120, //圆心x坐标
cy: 50 + Math.random() * 100, //圆心y坐标
}, ms, easing, function(){
setTimeout(animate, 1000);
});
}

}

Raphael绘制圆圈环绕方法的更多相关文章

  1. Android中View的绘制过程 onMeasure方法简述 附有自定义View例子

    Android中View的绘制过程 onMeasure方法简述 附有自定义View例子 Android中View的绘制过程 当Activity获得焦点时,它将被要求绘制自己的布局,Android fr ...

  2. Python解析Wav文件并绘制波形的方法

    资源下载 #本文PDF版下载 Python解析Wav文件并绘制波形的方法 #本文代码下载 Wav波形绘图代码 #本文实例音频文件night.wav下载 音频文件下载 (石进-夜的钢琴曲) 前言 在现在 ...

  3. 【转】Android中View的绘制过程 onMeasure方法简述 附有自定义View例子

    Android中View的绘制过程 当Activity获得焦点时,它将被要求绘制自己的布局,Android framework将会处理绘制过程,Activity只需提供它的布局的根节点. 绘制过程从布 ...

  4. 几何画板给word绘制图形的方法

    几何画板是一款专门用来绘图的工具,它里面有很多的绘图工具和功能菜单,都是专门为画图而设计的,比如一些理科的期刊杂志论文出版的时候,里面所涉及到的图形很多都是用几何画板画出来的.下面就根据几何画板教程来 ...

  5. raphael绘制矢量图2

    最近重新再次考虑了下raphael,也没办法把公司的项目给换成raphael的渲染了.大体上的效果稍微考了下其实并不难实现,难点大多集中在对路线以及子路线和方案的转换,以及位置的确定,几乎每操作一步都 ...

  6. canvas绘制清晰的方法

    很早就开始使用canvas,包括自己绘制各种图形,以及作为画布提供给诸如echarts,当canvas绘制细线条,特别是关于文字绘制会出现很模糊或者锯齿的感觉. <canvas ref=&quo ...

  7. 用C++实现绘制标尺的方法,使用了递归

    在这个例子当中将使用递归来实现一个打印标尺刻度的方法.首先是递归,函数调用其本身就叫递归,在需要将一项工作不断分为两项较小的.类似的工作时,递归非常有用,递归的方法被称为分而治之策略. 下面是一个wi ...

  8. 动画原理——绘制正弦函数&环绕运动&椭圆运动

    书籍名称:HTML5-Animation-with-JavaScript 书籍源码:https://github.com/lamberta/html5-animation  1.正弦函数.x位置递增, ...

  9. createjs绘制扇形的方法

    扇形由三段线条组成,两条直线和一条弧线,直线可以用createjs中的lineTo函数画出,弧线用Graphics.arc函数来画. 一.关于createjs中的Graphics.Arc API Gr ...

随机推荐

  1. 3240: [Noi2013]矩阵游戏

    Description 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何存储).她生成的这个矩阵满足一个神奇的性质:若用F[i][j]来表示矩阵中第i行第j列的 ...

  2. 运用 DataContractSerializer 存储本地对象

    public void Save(string filename,State state) { DataContractSerializer ds = new DataContractSerializ ...

  3. uva 11825

    刘书上例题  关于集合的动态规划 #include <cstdio> #include <cstdlib> #include <cmath> #include &l ...

  4. jsp的常用指令有哪些(编译指令/动作指令整理)

    jsp的常用指令有哪些(编译指令/动作指令整理) JSP动作指令 JSP - JSP中的脚本.指令.动作和注释

  5. Consumer closed input channel or an error occurred. events=0x8 channel is unrecoverably broken and will be disposed(待解决)

    跟文件读取有关?关闭文件读取试试. 有可能是读取文件 出现报错

  6. linux源码阅读笔记 void 指针

    void 指针的步长为1,而其他类型的指针的步长与其所定义的数据结构有关. example: 1 #include<stdio.h> 2 main() 3 { 4 int a[10]; 5 ...

  7. 终于明白公测的beta 源自何处了

    A very early version of a software product that may not contain all of the features that are planned ...

  8. POJ3087Shuffle'm Up(map)

    http://poj.org/problem?id=3087 题意 : 我只能说,,英语不好是硬伤...这个题比较别扭啊,不知道真正题意是不是我所想的,我先把我A了的代码按照的题意的意思说一下,就是说 ...

  9. lintcode 中等题:find the missing number 寻找缺失的数

    题目 寻找缺失的数 给出一个包含 0 .. N 中 N 个数的序列,找出0 .. N 中没有出现在序列中的那个数. 样例 N = 4 且序列为 [0, 1, 3] 时,缺失的数为2. 注意 可以改变序 ...

  10. 欧拉工程第69题:Totient maximum

    题目链接 欧拉函数φ(n)(有时也叫做phi函数)可以用来计算小于n 的数字中与n互质的数字的个数. 当n小于1,000,000时候,n/φ(n)最大值时候的n. 欧拉函数维基百科链接 这里的是p是n ...