~ubuntu-branches/ubuntu/vivid/monodevelop/vivid-proposed

« back to all changes in this revision

Viewing changes to external/xwt/Samples/Samples/DrawingPatternsAndImages.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-10-09 14:09:23 UTC
  • mfrom: (10.3.5)
  • Revision ID: package-import@ubuntu.com-20141009140923-s0d22u5f9kg8jvds
Tags: 5.5.0.227-1
* [b2c8331] Imported Upstream version 5.5.0.227 (Closes: #754316)
* [d210995] Delete obsolete patches
* [1b59ae1] Clear patch fizz, via quilt refresh
* [3dd147d] Fix error in configure.in which applies for tarball builds but 
  not git builds when running autoreconf
* [21c2a57] Remove Metacity references for good
* [3331661] Ensure NUnit 2.6.3 is installed
* [fd85c88] Build-depend on NuGet
* [a1ae116] Add WebKit to build dependencies, for Xwt moduleref resolution
* [9b4cf12] Since the GDB addin is integrated now, declare it in 
  debian/control
* [6231562] Correct NUnit links
* [3d2b693] Fix NuGet addin, by copying libs locally
* [74bf9a8] Don't symlink unused Mocks NUnit assembly
* [ade52b2] Ensure IKVM.Reflection is built with default (4.5) profile

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// 
2
 
// DrawingPatternsAndImages.cs
3
 
//  
4
 
// Author:
5
 
//       Lytico (http://limada.sourceforge.net)
6
 
//       Lluis Sanchez <lluis@xamarin.com>
7
 
// 
8
 
// Copyright (c) 2012 Xamarin Inc
9
 
// 
10
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
11
 
// of this software and associated documentation files (the "Software"), to deal
12
 
// in the Software without restriction, including without limitation the rights
13
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
 
// copies of the Software, and to permit persons to whom the Software is
15
 
// furnished to do so, subject to the following conditions:
16
 
// 
17
 
// The above copyright notice and this permission notice shall be included in
18
 
// all copies or substantial portions of the Software.
19
 
// 
20
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
 
// THE SOFTWARE.
27
 
using System;
28
 
using Xwt;
29
 
using Xwt.Drawing;
30
 
 
31
 
namespace Samples
32
 
{
33
 
        public class DrawingPatternsAndImages: Drawings
34
 
        {
35
 
                protected override void OnDraw (Context ctx, Rectangle dirtyRect)
36
 
                {
37
 
                        base.OnDraw (ctx, dirtyRect);
38
 
                        PatternsAndImages (ctx, 5, 5);
39
 
                }
40
 
                
41
 
                public void PatternsAndImages (Context ctx, double x, double y)
42
 
                {
43
 
                        ctx.Save ();
44
 
                        ctx.Translate (x, y);
45
 
                        
46
 
                        ctx.SetColor (Colors.Black);
47
 
                        // Dashed lines
48
 
 
49
 
                        ctx.SetLineWidth (2);
50
 
                        ctx.SetLineDash (15, 10, 10, 5, 5);
51
 
                        ctx.Rectangle (10, 10, 100, 100);
52
 
                        ctx.Stroke ();
53
 
                        ctx.SetLineDash (0);
54
 
                        
55
 
                        // Image
56
 
                        var arcColor = new Color (1, 0, 1);
57
 
                        ImageBuilder ib = new ImageBuilder (30, 30);
58
 
                        ib.Context.Arc (15, 15, 15, 0, 360);
59
 
                        ib.Context.SetColor (arcColor);
60
 
                        ib.Context.Fill ();
61
 
                        ib.Context.SetColor (Colors.DarkKhaki);
62
 
                        ib.Context.Rectangle (0, 0, 5, 5);
63
 
                        ib.Context.Fill ();
64
 
                        var img = ib.ToVectorImage ();
65
 
                        ctx.DrawImage (img, 0, 0);
66
 
                        ctx.DrawImage (img, 0, 50, 50, 10);
67
 
                        
68
 
                        ctx.Arc (100, 100, 15, 0, 360);
69
 
                        arcColor.Alpha = 0.4;
70
 
                        ctx.SetColor (arcColor);
71
 
                        ctx.Fill ();
72
 
                        
73
 
                        // ImagePattern
74
 
                        
75
 
                        ctx.Save ();
76
 
                        
77
 
                        ctx.Translate (x + 130, y);
78
 
                        ctx.Pattern = new ImagePattern (img);
79
 
                        ctx.Rectangle (0, 0, 100, 100);
80
 
                        ctx.Fill ();
81
 
                        ctx.Restore ();
82
 
                        
83
 
                        ctx.Restore ();
84
 
                        
85
 
                        // Setting pixels
86
 
                        
87
 
                        ctx.SetLineWidth (1);
88
 
                        for (int i=0; i<50;i++) {
89
 
                                for (var j=0; j<50;j++) {
90
 
                                        Color c = Color.FromHsl (0.5, (double)i / 50d, (double)j / 50d);
91
 
                                        ctx.Rectangle (i, j, 1, 1);
92
 
                                        ctx.SetColor (c);
93
 
                                        ctx.Fill ();
94
 
                                }
95
 
                        }
96
 
                }       
97
 
        }
98
 
}
99