Lessons · The language · 10 of 36
Colour, shape and images
Colours and shades, shape, shadow, see_through, outline, @images.
color: is the background. Colours have names (red, teal, gray…), shades from 50 (light)
to 900 (dark) like blue[600], or rgb(r, g, b) with an optional fourth number from 0
(see-through) to 1 (solid). A hex colour goes in quotes: "#FF6B6B".
main swatches:
arrange: row, center
space_between: 10
children:
named:
size: 20
color: coral
shape: circle
shade:
size: 20
color: teal[700]
shape: rounded
mixed:
size: 20
color: rgb(255, 120, 0, 0.6)
shadow: true
faded:
size: 20
color: "#6B4EFF"
see_through: 50
outline: 2, purple[900]
| Attribute | Does |
|---|---|
shape: |
square (default), rounded or circle |
shadow: true |
a soft drop shadow |
see_through: 50 |
50 % see-through (0 is solid, 100 invisible) |
outline: 2, red |
a 2-point line round the edge; name sides for some: outline: bottom 1, gray |
visible: false |
hides it (and the space it took) |
image: @photo.jpg |
a picture behind the children; add fill to cover the box, blurred to blur it |
@name means a file in the project's assets folder: @cat.png, @backgrounds/sky.jpg.
Typing @ lists the files. Web pictures go in quotes: image: "https://…/photo.jpg".
main card:
size: max, 40
image: @hero.png, fill
arrange: bottom left
space_inside: 16
children:
caption:
text: "Pictures come from the assets folder"
text_style: 16, bold, white
Every example here runs in Vi Studio: open it in your browser (phones too) and press Start learning on the welcome page. Each code block there has a Try it button that runs it in the phone preview.
More in The language
- Comments and names# comments, <# blocks #> and snake_case names.
- ContainersEverything on screen is a container; children one per line.
- Size and spacesize out of 100, and space_inside / between / around.
- Arrange and placeDirection, spot and spread; floating with place.
- Texttext and text_style.
- Buttons, inputs and other kindsbutton, input, search, icon, link and scrolling lists.
- Eventson_tap, on_hold, on_touch, on_swipe, on_change, on_submit, on_hit.
- Data: lists and objectsVariables, lists, objects and the list helpers.
- FunctionsYour own functions and the built-in ones.
- Conditions and loopsif / else, the inline if, and, or, not, for and while.
- Programs without a screenmain functions and print().
About Vi. Vi is a free, open-source programming language for building real mobile apps. You describe each screen in plain words, and Vi compiles it to React Native (Expo) for Android, iOS and the web. Its editor, Vi Studio, runs on Windows, in any browser and on your phone, with the app running live as you type. Read more about Vi.