Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn Red ? Fundamentals of Red

You're reading from   Learn Red ? Fundamentals of Red Get up and running with the Red language for full-stack development

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781789130706
Length 252 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Ivo Balbaert Ivo Balbaert
Author Profile Icon Ivo Balbaert
Ivo Balbaert
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Red's Mission FREE CHAPTER 2. Setting Up for Development 3. Using Words, Values, and Types 4. Code-Controlling Structures 5. Working with Series and Blocks 6. Using Functions and Objects 7. Working with Files 8. Parsing Data 9. Composing Visual Interfaces 10. Advanced Red 11. Assessments
12. Other Books You May Enjoy

An introduction to the draw dialect

Draw is a Red dialect created to make it easy to draw two-dimensional geometrical shapes such as circles, rectangles, and animations. It makes use of VID, so the needs 'view has to appear in the header. To start with a simple example, here is how to draw a circle:

;-- see Chapter09/first-draw-example.red:
view
[
base 100x100 cyan draw [
line 20x0 75x50
pen red
circle 35x50 20
]
]

We draw on a base face and start a draw block. In it, we draw a line from a starting point at 20 x 0 to an end point at 75 x 50. Then, we define a pen with the color red and use it to draw a circle with a radius of 20 and center at 35 x 50:

=> Now answer question 9 from the Questions section.

Instead of a base, you can also add drawings on an existing image.

The draw dialect is very elaborate, here are some of the things you can try...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image