2
// DrawingPatternsAndImages.cs
5
// Lytico (http://limada.sourceforge.net)
6
// Lluis Sanchez <lluis@xamarin.com>
8
// Copyright (c) 2012 Xamarin Inc
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:
17
// The above copyright notice and this permission notice shall be included in
18
// all copies or substantial portions of the Software.
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
33
public class DrawingPatternsAndImages: Drawings
35
protected override void OnDraw (Context ctx, Rectangle dirtyRect)
37
base.OnDraw (ctx, dirtyRect);
38
PatternsAndImages (ctx, 5, 5);
41
public void PatternsAndImages (Context ctx, double x, double y)
46
ctx.SetColor (Colors.Black);
50
ctx.SetLineDash (15, 10, 10, 5, 5);
51
ctx.Rectangle (10, 10, 100, 100);
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);
61
ib.Context.SetColor (Colors.DarkKhaki);
62
ib.Context.Rectangle (0, 0, 5, 5);
64
var img = ib.ToVectorImage ();
65
ctx.DrawImage (img, 0, 0);
66
ctx.DrawImage (img, 0, 50, 50, 10);
68
ctx.Arc (100, 100, 15, 0, 360);
70
ctx.SetColor (arcColor);
77
ctx.Translate (x + 130, y);
78
ctx.Pattern = new ImagePattern (img);
79
ctx.Rectangle (0, 0, 100, 100);
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);