source: Dev/trunk/src/client/dojox/gfx/tests/test_linearGradient.html

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.8 KB
Line 
1<!DOCTYPE html>
2<html>
3<head>
4<title>Dojo Unified 2D Graphics</title>
5<style type="text/css">
6        @import "../../../dojo/resources/dojo.css";
7        @import "../../../dijit/tests/css/dijitTests.css";
8</style>
9<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script>
11<script type="text/javascript">
12dojo.require("dojox.gfx");
13dojo.require("dojo.colors");
14dojo.require("dojox.gfx");
15dojo.require("dojox.gfx.shape");
16dojo.require("dojox.gfx.path");
17dojo.require("dojox.gfx.arc");
18
19createSurface = function(){
20        var surface = dojox.gfx.createSurface("grad", 300, 300);
21        surface.whenLoaded(makeShapes);
22};
23
24makeShapes = function(surface){
25        var lg1 = {
26                type: "linear",
27                x1: 0, y1: 0,
28                x2: 300, y2: 0,
29                colors: [
30                        { offset: 0,   color: [0, 0, 0, 0] },
31                        { offset: 0.1, color: "#000000" },
32                        { offset: 0.2, color: "red" },
33                        { offset: 0.3, color: "rgb(0,255,0)" },
34                        { offset: 0.4, color: "blue" },
35                        { offset: 0.5, color: "#ff0" },
36                        { offset: 0.6, color: [128] },
37                        { offset: 0.7, color: [128, 128, 64] },
38                        { offset: 1,   color: [0, 255, 0, 0] }
39                ]
40        };
41        var lg2 = {
42                type: "linear",
43                x1: 0, y1: 0,
44                x2: 300, y2: 0,
45                colors: [
46                        { offset: 0.2, color: "red" },
47                        { offset: 0.3, color: "yellow" }
48                ]
49        };
50        var group = surface.createGroup();
51        var rect1 = surface.createRect({
52                width:  300,
53                height: 100
54        });
55        rect1.setFill(lg1);
56        var rect2 = surface.createRect({
57                y: 150,
58                width:  300,
59                height: 100
60        });
61        rect2.setFill(lg2);
62        group.add(rect1);
63        group.add(rect2);
64};
65dojo.addOnLoad(createSurface);
66</script>
67<style>
68v:group { text-align: left; }
69#grad { width: 300px; height: 300px; }
70</style>
71</head>
72<body>
73<h1>dojox.gfx Linear Gradient test</h1>
74<div id="grad"></div>
75</body>
76</html>
Note: See TracBrowser for help on using the repository browser.