SHAPES & TRANSFORMS. Chapter 12 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ.

Similar documents
LAYOUT. Chapter 3 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

CS3240 Human-Computer Interaction Lab Sheet Lab Session 2

STYLES AND BEHAVIORS

Scalable Vector Graphics (SVG) vector image World Wide Web Consortium (W3C) defined with XML searched indexed scripted compressed Mozilla Firefox

Paint/Draw Tools. Foreground color. Free-form select. Select. Eraser/Color Eraser. Fill Color. Color Picker. Magnify. Pencil. Brush.

Adobe Photoshop Sh S.K. Sublania and Sh. Naresh Chand

Shape and Line Tools. tip: Some drawing techniques are so much easier if you use a pressuresensitive

Generating Vectors Overview

GraphWorX64 Productivity Tips

How to create shapes. Drawing basic shapes. Adobe Photoshop Elements 8 guide

Graphic Design & Digital Photography. Photoshop Basics: Working With Selection.

ROUTED EVENTS. Chapter 5 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

EDITING SHAPES. Lesson overview

XAML. Chapter 2 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon Understanding XAML

Paint Tutorial (Project #14a)

Google SketchUp. and SketchUp Pro 7. The book you need to succeed! CD-ROM Included! Kelly L. Murdock. Master SketchUp Pro 7 s tools and features

How to draw and create shapes

Describe Plane Shapes

APPLICATIONS of AFFINE TRANSFORMATION. Introduction

5. Canvas overview. Cricut Design Space User Manual. Design Panel

Adobe InDesign CS6 Tutorial

Part II: Creating Visio Drawings

Using Flash Animation Basics

Create a Swirly Lollipop Using the Spiral Tool Philip Christie on Jun 13th 2012 with 12 Comments

Create an Adorable Hedgehog with Basic Tools in Inkscape Aaron Nieze on Sep 23rd 2013 with 5 Comments

ADOBE TRAINING CS6 PHOTOSHOP BASICS: EDITING PHOTOS & WORKING WITH TEXT - 1

FactoryLink 7. Version 7.0. Client Builder Reference Manual

Creating Vector Shapes Week 2 Assignment 1. Illustrator Defaults

Controlling the Control Palette

A QUICK TOUR OF ADOBE ILLUSTRATOR CC (2018 RELEASE)

Step 1: Create A New Photoshop Document

Using Microsoft Word. Tables

Creating Digital Illustrations for Your Research Workshop III Basic Illustration Demo

Krita Vector Tools

Learning to use the drawing tools

Unit 1, Lesson 1: Moving in the Plane

5 Drawing Stuff in 2D

L E S S O N 2 Background

Drawing shapes and lines

CS-202 Introduction to Object Oriented Programming

PLC Papers Created For:

User Manual Version 1.1 January 2015

This document should only be used with the Apple Macintosh version of Splosh.

01 - Basics - Toolbars, Options and Panels

Microsoft Visio Working with Shapes

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?


SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

Adobe illustrator Introduction

Strategy. Using Strategy 1

INTERMEDIATE WORD. Class Objective:

Chapter 1. Getting to Know Illustrator

Picket Patterns. Overview

Content provided in partnership with Que, from the book Show Me Microsoft Office Access 2003 by Steve JohnsonÃÃ

MET 107 Drawing Tool (Shapes) Notes Day 3

Word 2003: Flowcharts Learning guide

Custom Shapes As Text Frames In Photoshop

Getting Started with Silo

4.0 - ENGRAVING TEXT AND A BARCODE ON ALUMILAZ

MS WORD INSERTING PICTURES AND SHAPES

Photoshop / Editing paths

UV Mapping to avoid texture flaws and enable proper shading

EXAMINATIONS 2016 TRIMESTER 2

JavaFX Technology Building GUI Applications With JavaFX - Tutorial Overview

Lesson 1: Creating T- Spline Forms. In Samples section of your Data Panel, browse to: Fusion 101 Training > 03 Sculpt > 03_Sculpting_Introduction.

BASICS OF MOTIONSTUDIO

GDL Toolbox 2 Reference Manual

7/21/2009. Chapters Learning Objectives. Fillet Tool

InDesign Tools Overview

Inkscape Interface. commands panes snap. tool. menus. controls. controls. toolbox. canvas. page. palette

SETTINGS AND WORKSPACE

Do Now # 1 Label the Photoshop Interface.

Solution Notes. COMP 151: Terms Test

FrontPage 98 Quick Guide. Copyright 2000 Peter Pappas. edteck press All rights reserved.

Creating a Title Block & Border Using Chief Architect. Architectural Design & Residential Construction Penncrest High School

Ancient Cell Phone Tracing an Object and Drawing with Layers

DOING MORE WITH WORD: MICROSOFT OFFICE 2010

Creating a Spreadsheet by Using Excel

5Using Drawings, Pictures. and Graphs. Drawing in ReportSmith. Chapter

The American University in Cairo. Academic Computing Services. Word prepared by. Soumaia Ahmed Al Ayyat

3 Polygonal Modeling. Getting Started with Maya 103

lundi 7 janvier 2002 Blender: tutorial: Building a Castle Page: 1

Label Design Program Label Artist-II Manual Rev. 1.01

Adding Objects Creating Shapes Adding. Text Printing and Exporting Getting Started Creating a. Creating Shapes Adding Text Printing and Exporting

Edupen Pro User Manual

Document Editor Basics

- Is the process of combining texts and graphics layout to produce publications e.g. cards,

Designer Reference 1

Lesson 1. Unit 2 Practice Problems. Problem 2. Problem 1. Solution 1, 4, 5. Solution. Problem 3

4 TRANSFORMING OBJECTS

2 Working with Selections

Note: many examples in this section taken or adapted from Pro WPF 4.5 C#, Matthew MacDonald, apress, 2012, pp

Adobe InDesign CS6 Tutorial

WIRE BASICS ESTIMATED TIME REQUIRED. This tutorial will teach you the basics of sketching wires and using them as contours for solid objects.

MULTIMEDIA WEB DESIGN

Drawing a Circle. 78 Chapter 5. geometry.pyde. def setup(): size(600,600) def draw(): ellipse(200,100,20,20) Listing 5-1: Drawing a circle

DESIGNING A WEBSITE LAYOUT IN PHOTOSHOP CS4. Step 1

ITEC185. Introduction to Digital Media

Adobe Illustrator. Quick Start Guide

BDM s Annotation User Guide

Transcription:

SHAPES & TRANSFORMS Chapter 12 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon - 2014 Understanding Shapes The simplest way to draw 2-D graphical content in a WPF user interface is to use shapes dedicated classes that represent simple lines, ellipses, rectangles, and polygons shapes are known as drawing primitives. 1

Understanding Shapes Shapes are elements. This has the following important consequences: 1. Shapes draw themselves. You don t need to manage the invalidation and painting process. 2. Shapes are organized in the same way as other elements. In other words, you can place a shape in any of the layout containers 3. Shapes support the same events as other elements. That means you don t need to go to any extra work to deal with focus, key presses, mouse movements, and mouse clicks. The Shape Classes Every shape derives from the abstract System.Windows.Shapes.Shape class. Although the Shape class can t do anything on its own, it defines a small set of important properties, which are listed in Table 12-1. 2

Rectangle and Ellipse To create either one, set the familiar Height and Width properties (inherited from FrameworkElement) to define the size of your shape, And then set the Fill or Stroke property (or both) to make the shape visible. You re also free to use properties such as MinHeight, MinWidth, HorizontalAlignment, VerticalAlignment, and Margin. Note If you fail to set the Stroke or Fill property, your shape won t appear at all. Rectangle and Ellipse 3

Rectangle and Ellipse The Ellipse class doesn t add any properties. The Rectangle class adds just two: RadiusX and RadiusY. When set to nonzero values, these properties allow you to create nicely rounded corners. You can think of RadiusX and RadiusY as describing an ellipse that s used just to fill in the corners of the rectangle. For example, if you set both properties to 10, WPF draws your corners by using the edge of a circle that s 10 units wide. Rectangle and Ellipse 4

Rectangle and Ellipse If you don t supply the Height and Width properties, the shape is sized based on its container. A better example can be made with the Grid container. Here, the Grid fills the entire window. The Grid contains a single proportionately sized row, which fills the entire Grid. Finally, the ellipse fills the entire row. Rectangle and Ellipse So far, you ve seen how to size a Rectangle and an Ellipse, but what about placing them exactly where you want them? The ideal container is the Canvas, which forces you to specify the coordinates of each shape by using the attached Left, Top, Right, or Bottom properties. This gives you complete control over how shapes overlap: 5

Line The Line shape represents a straight line that connects one point to another. The starting and ending points are set by four properties: X1 and Y1 (for the first point) and X2 and Y2 (for the second point). The Fill property has no effect for a line. You must set the Stroke property. There s no way to create a curved line with Line or Polyline shapes. Instead, you need the more advanced Path class described in Chapter 13. Polyline The Polyline class allows you to draw a sequence of connected straight lines. You simply supply a list of X and Y coordinates by using the Points property. Technically, the Points property requires a PointCollection object, but you fill this collection in XAML by using a lean string-based syntax. You simply need to supply a list of points and add a space or a comma between each coordinate. 6

Polyline Polygon The Polygon is virtually the same as the Polyline. Like the Polyline class, the Polygon class has a Points collection that takes a list of coordinates. The only difference is that the Polygon adds a final line segment that connects the final point to the starting point. You can fill the interior of this shape by using the Fill brush. 7

Using Transforms Many drawing tasks can be made simpler with the use of a transform an object that alters the way a shape or element is drawn by quietly shifting the coordinate system it uses. In WPF, transforms are represented by classes that derive from the abstract System.Windows.Media.Transform class, as listed in Table 12-5. Using Transforms 8

Using Transforms Technically, all transforms use matrix math to alter the coordinates of your shape. However, using the prebuilt transforms such as TranslateTransform, RotateTransform, ScaleTransform, and SkewTransform is far simpler than using the MatrixTransform and trying to work out the correct matrix for the operation you want to perform. When you perform a series of transforms with the TransformGroup, WPF fuses your transforms together into a single MatrixTransform, ensuring optimal performance. Using Transforms Transforms are one of those quirky concepts that turn out to be extremely useful in a variety of contexts. Some examples include the following: Angling a shape: So far, you ve been stuck with horizontally aligned rectangles, ellipses, lines, and polygons. Using the RotateTransform, you can turn your coordinate system to create certain shapes more easily. Repeating a shape: Many drawings are built using a similar shape in several places. Using a transform, you can take a shape and then move it, rotate it, resize it, and so on. Animation: You can create sophisticated effects with the help of a transform, such as by rotating a shape, moving it from one place to another, and warping it dynamically. 9

Transforming Shapes To transform a shape, you assign the RenderTransform property to the transform object you want to use. Depending on the transform object you re using, you ll need to fill in different properties to configure it, as detailed in Table 12-5. For example, if you re rotating a shape, you need to use the RotateTransform, and supply the angle in degrees. Here s an example that rotates a square by 25 degrees: Transforming Shapes 10

Transforming Shapes Sometimes you ll want to rotate a shape around a different point. The RotateTransform, like many other transform classes, provides a CenterX property and a CenterY property. Transforming Shapes There s a clear limitation to using the CenterX and CenterY properties of the RotateTransform. These properties are defined using absolute coordinates, which means you need to know the exact center point of your content. This property sets the center point by using a proportional coordinate system that stretches from 0 to 1 in both dimensions. In other words, the point (0, 0) is designated as the top-left corner and (1, 1) is the bottom-right corner. 11

Transforming Shapes 12