毕业设计代码记录

最近开始搞毕业论文了,亚历山大,记录一点毕业设计需要用的代码

<html>  
  <head>  
        <meta charset="utf-8">  
        <title>颜色插值</title>  
  </head> 
  <style>

  </style>
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>

var width = 400,
    height = 400;
    
var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

var a = d3.rgb(255,0,0);    //红色
var b = d3.rgb(0,255,0);    //绿色
 
var compute = d3.interpolate(a,b);

var linear = d3.scale.linear()
                .domain([0,150])
                .range([0,1]);

var rects = svg.selectAll("rect")
                .data(d3.range(150))
                .enter()
                .append("rect")
                .attr("x",function(d,i){
                    return i%15 * 15;
                })
                .attr("y",function(d,i){
                    return Math.floor(i/15) * 15;
                })
                .attr("width",15)
                .attr("height",15)
                .style("fill",function(d){
                    return compute(linear(d));
                })
                .on("mouseover",function(d){
                    d3.select(this)
                        .style("fill","yellow");
                })
                .on("mouseout",function(d){
                    d3.select(this)
                        .style("fill",compute(linear(d)).toString());
                });

//定义一个线性渐变
var defs = svg.append("defs");

var linearGradient = defs.append("linearGradient")
                        .attr("id","linearColor")
                        .attr("x1","0%")
                        .attr("y1","0%")
                        .attr("x2","100%")
                        .attr("y2","0%");

var stop1 = linearGradient.append("stop")
                .attr("offset","0%")
                .style("stop-color",a.toString());

var stop2 = linearGradient.append("stop")
                .attr("offset","100%")
                .style("stop-color",b.toString());

//添加一个矩形,并应用线性渐变
var colorRect = svg.append("rect")
                .attr("x", 15)
                .attr("y", 200)
                .attr("width", 200)
                .attr("height", 30)
                .style("fill","url(#" + linearGradient.attr("id") + ")")
                .on("mouseover",function(d){
                    d3.select(this)
                        .style("fill","yellow");
                })
                .on("mouseout",function(d){
                    d3.select(this)
                        .style("fill","url(#" + linearGradient.attr("id") + ")");
                });

</script>
        
    </body>  
</html>

转自:http://www.ourd3js.com/wordpress/?p=1111

http://www.hcharts.cn/demo/highmaps.php
http://d3js.org/
http://www.ourd3js.com/wordpress/?p=1111
http://blog.csdn.net/kalision/article/details/40503393

时间: 2024-10-10 23:21:26

毕业设计代码记录的相关文章

MVVM 代码记录

  一.XML <Page x:Class="MVVM.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MVVM" xmlns:d="http://schemas

代码记录生活-倒计时

我不会表达我的内心世界,那么我就用代码来记录我的生活,用一行行代码来表达我的心情. 虽然我写的代码都很简单,毕竟我是初学者,以后会慢慢的好的. 那么今天就先上传我昨天写的一个小计时器吧,就只有一个计时器功能,其他的没有. 源码分享地址链接:http://pan.baidu.com/s/1eQcT0A2 密码:4xru 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using

OpenCV学习代码记录——Hough线段检测

很久之前学习过一段时间的OpenCV,当时没有做什么笔记,但是代码都还在,这里把它贴出来做个记录. 代码放在码云上,地址在这里https://gitee.com/solym/OpenCVTest/tree/master/OpenCVTest #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> // http://blog.csdn.net/zh

OpenCV学习代码记录——canny边缘检测

很久之前学习过一段时间的OpenCV,当时没有做什么笔记,但是代码都还在,这里把它贴出来做个记录. 代码放在码云上,地址在这里https://gitee.com/solym/OpenCVTest/tree/master/OpenCVTest. #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> // c

OpenCV学习代码记录——轮廓(contour)检测

很久之前学习过一段时间的OpenCV,当时没有做什么笔记,但是代码都还在,这里把它贴出来做个记录. 代码放在码云上,地址在这里https://gitee.com/solym/OpenCVTest/tree/master/OpenCVTest #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> // cv

OpenCV学习代码记录—— Snake轮廓

很久之前学习过一段时间的OpenCV,当时没有做什么笔记,但是代码都还在,这里把它贴出来做个记录. 代码放在码云上,地址在这里https://gitee.com/solym/OpenCVTest/tree/master/OpenCVTest #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> #include <opencv2/legac

OpenCV学习代码记录——人脸检测

很久之前学习过一段时间的OpenCV,当时没有做什么笔记,但是代码都还在,这里把它贴出来做个记录. 代码放在码云上,地址在这里https://gitee.com/solym/OpenCVTest/tree/master/OpenCVTest #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <opencv2/objdetect.hpp> #include <opencv2/img

第六章代码记录1

record_def.s 1 .equ RECORD_FIRSTNAME, 0 #记录数据:firstName:40字节 0-39 2 .equ RECORD_LASTNAME, 40 #记录数据:lastName:40字节 40-79 3 .equ RECORD_ADDRESS, 80 #记录数据:address:240字节 80-319 4 .equ RECORD_AGE, 320 #记录数据:age:4字节 320-323 5 .equ RECORD_SIZE, 324 #记录数据:siz

Unity学习笔记 之 触发Unity UI 的 Button 事件 的代码记录

首先奉献上 Button 所触发的事件 的脚本代码. 文件名为testButtonEvent using UnityEngine; using System.Collections; //1.引入 UI . using UnityEngine.UI; public class testButtonEvent : MonoBehaviour { //2.定义一个目标对象. public Text targetTextObject; // Use this for initialization vo