Raphael绘制圆圈环绕方法
$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绘制圆圈环绕方法的更多相关文章
- Android中View的绘制过程 onMeasure方法简述 附有自定义View例子
Android中View的绘制过程 onMeasure方法简述 附有自定义View例子 Android中View的绘制过程 当Activity获得焦点时,它将被要求绘制自己的布局,Android fr ...
- Python解析Wav文件并绘制波形的方法
资源下载 #本文PDF版下载 Python解析Wav文件并绘制波形的方法 #本文代码下载 Wav波形绘图代码 #本文实例音频文件night.wav下载 音频文件下载 (石进-夜的钢琴曲) 前言 在现在 ...
- 【转】Android中View的绘制过程 onMeasure方法简述 附有自定义View例子
Android中View的绘制过程 当Activity获得焦点时,它将被要求绘制自己的布局,Android framework将会处理绘制过程,Activity只需提供它的布局的根节点. 绘制过程从布 ...
- 几何画板给word绘制图形的方法
几何画板是一款专门用来绘图的工具,它里面有很多的绘图工具和功能菜单,都是专门为画图而设计的,比如一些理科的期刊杂志论文出版的时候,里面所涉及到的图形很多都是用几何画板画出来的.下面就根据几何画板教程来 ...
- raphael绘制矢量图2
最近重新再次考虑了下raphael,也没办法把公司的项目给换成raphael的渲染了.大体上的效果稍微考了下其实并不难实现,难点大多集中在对路线以及子路线和方案的转换,以及位置的确定,几乎每操作一步都 ...
- canvas绘制清晰的方法
很早就开始使用canvas,包括自己绘制各种图形,以及作为画布提供给诸如echarts,当canvas绘制细线条,特别是关于文字绘制会出现很模糊或者锯齿的感觉. <canvas ref=&quo ...
- 用C++实现绘制标尺的方法,使用了递归
在这个例子当中将使用递归来实现一个打印标尺刻度的方法.首先是递归,函数调用其本身就叫递归,在需要将一项工作不断分为两项较小的.类似的工作时,递归非常有用,递归的方法被称为分而治之策略. 下面是一个wi ...
- 动画原理——绘制正弦函数&环绕运动&椭圆运动
书籍名称:HTML5-Animation-with-JavaScript 书籍源码:https://github.com/lamberta/html5-animation 1.正弦函数.x位置递增, ...
- createjs绘制扇形的方法
扇形由三段线条组成,两条直线和一条弧线,直线可以用createjs中的lineTo函数画出,弧线用Graphics.arc函数来画. 一.关于createjs中的Graphics.Arc API Gr ...
随机推荐
- IDENTITY属性使用
转自:http://www.cnblogs.com/seusoftware/p/3804333.html 一. 获取IDENTITY列值插入了数据,有时还需要获取刚才生成的序列值另作他用,返回给前端也 ...
- 剑指offer--面试题16
#include<stack> //思路:遍历链表过程中,将各个指针入栈,再出栈进行反转 ListNode* ReverseList(ListNode* pHead) { if(pHead ...
- js刷新
jquery刷新页面的实现代码(局部及全页面刷新) 发布:mdxy-dxy 字体:[增加 减小] 类型:转载 jquery刷新页面的实现代码(局部及全页面刷新) ,需要的朋友可以参考下. 局部刷新: ...
- C语言关键字register、extern、static
C语言中: 一.register变量 关键字regiter请求编译器尽可能的将变量存在CPU的寄存器中.有以下几点注意的地方. register变量必须是能被CPU寄存器所接受的类型,这通常意味着re ...
- IOS NSPredicate 查询、搜索
简述:Cocoa框架中的NSPredicate用于查询,原理和用法都类似于SQL中的where,作用相当于数据库的过滤取. 最常用到的函数 + (NSPredicate *)predicateWith ...
- hdu 2837 Calculation
公式:a^b%p=a^(b%phi(p)+phi(p))%p b>=phi(p) #include<iostream> #include<stdio.h> #incl ...
- windows下安装ubantu
首先声明我是一个linux大菜鸟,之所以学这个,一个是好玩,另外做DL的一些软件如Caffe要在这个平台上运行,所以没事就鼓捣鼓捣.linux是一种内核,市场上支持这种内核的操作系统有uban ...
- 【nginx运维基础(6)】Nginx的Rewrite语法详解
概述 重写URL是非常有用的一个功能,因为它可以让你提高搜索引擎阅读和索引你的网站的能力:而且在你改变了自己的网站结构后,无需要求用户修改他们的书签,无需其他网站修改它们的友情链接:它还可以提高你的网 ...
- phpmyadmin导入大sql文件失败解决办法
摘自:http://www.xunway.com/info/post/499.asp 昨天小编的一个客户在在利用phpmyadmin导入大sql文件的时候,总是提示错误,反应给小编,小编也是第一次遇到 ...
- HackDemo.java
import java.io.*; import java.awt.*; public class HackDemo{ public static void main(String args[]) t ...