10. 剪切蒙版 Masking Layers - Origami Studio 教程


下载教程文件** ·····密码: ahgt**

选择对应名称的文件夹下载,内包含一个(开始)和一个(已完成)文件;(开始)文件用来和教程同步操作,(已完成)是最终结果。


Add mask behavior to layers and their underlying children.

Masking in Origami is a lot like other design tools, with the added bonus of being able to use masks to create advanced interactions and animations. We are going to prototype Messenger photo radius changes, which occur on lightbox open and close. If you haven't already, download the tutorial files.

遮罩在 Origami 中跟在其他的设计工具一样,还可以使用遮罩来创建高级互动和动画。这次我们要实现灯箱效果开和关时照片圆角半径的变化。下载教程文件。

Setting up 配置

We have already set up Image Container to change its Scale and Position properties to turn into a lightbox on Tap. The last thing we need to do is set a change in rounded-corners on Image itself. The Image needs a Radius of 28 when within-conversation, but a Radius of 0 (no Radius) when expanded to a lightbox.

打开标记为(开始)的文件,已经配置好了点击图片灯箱效果的开关交互。现在我们只需要做的最后一件事,给图片设置圆角的变化。
当在对话列表内时,图像半径为28,扩展为灯箱时,半径为0(无半径)。

This Image should have rounded corners within the conversation thread. 这种状态下应该要有圆角。

Preparing a mask layer 准备一个剪切蒙版图层

Image layers do not have a Radius property. To create a radius on the Image layer, we will need to use as layer type that does have a Radius property and use that as a mask.

Image 图层没有圆角属性。要给图像创建半径,需要使用具有Radius属性的层类型,并将其用作剪切蒙版。

Rounded Rectangle is a layer type that does have a Radius property. Click the New Layer button and type to find Rounded Rectangle. Press Return ⏎ once it appears.

圆角矩形有 Radius 属性,所以我们用 Rounded Rectangle 图层。新建一个。

Place the new Rounded Rectangle layer in the same Group as Image, below the image itself. This is because our Image layer will be masked onto the Rounded Rectangle.

把 Rounded Rectangle 图层放在和图像相同的组内,图像下层。
因为图像层将被蒙上圆角矩形。

Creating a mask 创建一个蒙版图层

To mask Image, we need to select the layer we want to use as a mask (Rounded Rectangle) then navigate to Layer > Use as Mask ⌥⌘M.

要给图像做剪切蒙版,需要选中 Rounded Rectangle 图层,点击导航栏 Layer > Use as Mask Alt Cmd M

Remember to have the Rounded Rectangle layer selected. 要选择 Rounded Rectangle 图层。

Editing a mask 编辑剪切蒙版

Image, directly above the Rounded Rectangle, is now masked to the shape of Rounded Rectangle. Changing any of the Rounded Rectangle properties will visually reflect on Image too.

图像现在被蒙版成了圆形矩形的形状。修改 Rounded Rectangle 图层的属性会应用在 Image 图层上。

Change the Rounded Rectangle Size and Position properties to match Image, since would like them to be the same. The Size property of Image is 375 by 250. Our desired Radius is 28.

将 Rounded Rectangle 图层的大小、位置属性更改为和图像一样的。Image 的 Size 属性是375×250。圆角是 28,所以 Radius 的值输入 28。

If you have followed correctly, the Position property should be already at `0`. 圆角矩形的尺寸调对了的话位置坐标应该都是 0 。

Transitioning with a mask 转换圆角动画

We would like the Radius to change to 0 when Image is receives a Tap and transitions to a lightbox. A Transition patch has already been prepared in the Patch Editor, so that the animation begins at 28 and ends at 0.

当 Image 接收到 Tap 并转换到 lightbox 时,我们希望 Radius 为 0。Transition 模块已经添加到编辑器中了,所以动画从28开始,以0结束。

Our top-most Transition patch has values already added. 最上面的 Transition 模块就是给圆角半径变换准备的,值已经填好了。

The last step is to connect the Transition patch output to the Radius property of the Rounded Rectangle. Go ahead and connect this. The Radius of mask now changes, which in turn changes the Image layer masked to this.

最后一步,把 Transition 模块的输出口连接到 Rounded Rectangle 图层的 Radius 属性。

Connect the Transition output to the Radius property by clicking and dragging to the Layers panel. 按住拖动输出口到属性名称上。

If your prototype does not work properly, double-check the order of your layers, and make sure you have your Rounded Rectangle used as the mask. Inspect the Layers panel to see which layers and masks are affecting each other, indicated by symbols.

如果原型跟预期的不一样,检查图层的顺序,并确定是给 Rounded Rectangle 图层添加剪切蒙版的。
检查图层面板,查看哪些图层和剪切蒙版相互影响,由符号表示。

The downward arrow shows the layer *being* masked. The corner-glyph shows which layer is acting as the mask. 又向下箭头的是被剪切的图层。右下角有个小图标的是蒙版图层。

相关课程

4.添加逻辑 Adding Logic
给过渡和流程添加逻辑。

7. 切换屏幕 Screen Transitions
创建屏幕切换流程。

相关案例

3. Messenger Photo View
图片在对话和全屏模式之间切换的动画。

相关图层

Image File Rounded Rectangle


NEXT UP
11. 介绍循环 Introduction to Loops
使用循环降低原型复杂度,复用常见元素能节省时间。


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,219评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,363评论 1 293
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,933评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,020评论 0 206
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,400评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,640评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,896评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,597评论 0 199
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,327评论 1 244
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,581评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,072评论 1 261
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,399评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,054评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,083评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,849评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,672评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,585评论 2 270

推荐阅读更多精彩内容