Dosen原創(chuàng)
開始學(xué)習(xí)Framerjs寇壳,邊學(xué)邊翻譯太伊,也加了一些我學(xué)習(xí)過程中的理解。寫下來留作以后查閱箫锤,看官如果發(fā)現(xiàn)有地方寫的不對請指出贬蛙。轉(zhuǎn)載請聯(lián)系作者雨女。
Layers????? 層
A layer is a rectangle that draws elements. Layers can display images, videos or text. Every layer inherits a set of default properties: width, height and a blue background.
層是一個(gè)繪制的矩形元素。層可以顯示圖片速客,視頻或文字戚篙。每個(gè)層都繼承一系列的默認(rèn)屬性:寬,高溺职,和一個(gè)藍(lán)色背景岔擂。
這段代碼創(chuàng)建了一個(gè)位置在0.0,寬高為100px的層浪耘。
層的概念就像一個(gè)容器乱灵,所有可視元素都要放在這個(gè)容器里。
Properties????? 屬性
A layers position, size and looks are defined by its properties. Besides being able to define an image, background, or video, you can also transform, hide layers, scale layers and more.
一個(gè)層的位置七冲、尺寸痛倚,看起來的樣子是通過它的屬性來定義的。不光可以定義一個(gè)圖片澜躺、背景或視頻蝉稳,你還可以對層進(jìn)行移動、隱藏掘鄙、縮放耘戚、等
這段代碼創(chuàng)建了一個(gè)名字是layerB的層,顏色是#2DD7AA操漠,寬高為60px收津,縮放值為1,描邊3px浊伙。
You can also define and override properties after having created a layer.
你也可以在創(chuàng)建了一個(gè)層后對它的屬性進(jìn)行再定義撞秋、重寫。
這段代碼對layerB的描邊嚣鄙,旋轉(zhuǎn)吻贿,透明度,縮放屬性進(jìn)行了更改哑子,再定義廓八。
Positioning????? 位置
A layer can be positioned with its x and y properties. These values define the distance from the top-left corner of the canvas. The minX, minY, midX, midY, maxX and maxY values can also be used to position a layer.
一個(gè)層可以通過它的x,y屬性進(jìn)行定位赵抢。這些值表示層到視圖左上角的距離剧蹂。minX(左上角到圖層最左的距離),minY(左上角到圖層最頂?shù)木嚯x)烦却,midX(左上角到圖層水平中心的距離)宠叼,midY(左上角到圖層垂直中心的距離),maxX(左上角到圖層最右的距離),maxY(左上角到圖層最底的距離)冒冬,這些值也可以被用于定義層的位置伸蚯。
The distance from the top-left corner of the canvas to the center of a layer can be calculated with midX and middy.
從視圖左上角到層中心的距離可以用midX和midY計(jì)算。
You can center a layer within its superLayer (see Hierarchy), or on the screen by calling the center() function. Layers can also be exclusively centered horizontally or vertically.
你可以把一個(gè)層居中到它的父類層简烤,或者使用center()方法剂邮。層就可以到中心點(diǎn),或水平中心或垂直中心横侦。
Hierarchy????? 層級
Layers can have a parent and/or children. Parent layers are called superLayers, and child layers are called subLayers. Layers inherit properties from their superLayers.
層可以有父層挥萌、子層。父層被稱作superLayers(超級層枉侧?)引瀑,子層被稱作subLayers(節(jié)點(diǎn)層?)榨馁。層繼承父層的屬性憨栽。
這段代碼兩行的意思是一樣的。第一行是指定layerB的父層為layerA翼虫,第二行是指定layerA的子層為layerB屑柔。
Layer types????? 層的類型
Layers can contain images, videos and text.
層可以容納圖片、視頻珍剑、文字锯蛀。
這段代碼示例了添加不同類型元素的方法。
Summary????? 概要
— Layers are defined by properties
使用屬性定義層次慢。
— Layers have hierarchy and inherit properties from their parents
層有層級并且從它們的父類中繼承屬性。
— Layers can be transformed, scaled, masked, rotated and more
層可以被移動翔曲、縮放迫像、遮罩、旋轉(zhuǎn)瞳遍,等闻妓。
— Layers can contain images, videos and text
層可以容納圖片、視頻掠械、文字由缆。