😍
Framer API 中文版
  • 写在前面
  • 从这里开始
    • 介绍
      • 快速开始
      • 基础
    • 教程
      • 准备 Setup
      • 引入 Slider 组件
      • Slider组件的元素
      • 拖动 & MotionValue
      • Hooks & 传递数据
      • 完成
      • 回顾
    • 简要案例
      • Frame
      • Stack
      • Animate
      • Gestures
      • Dragging 拖拽
      • Scrolling 滚动
      • Paging 翻页
      • Tranforms 变换
      • Variants 动画状态组
  • LIBRARY 库
    • Frame
      • Layout 布局
      • Visual 视觉
      • Transform 变换
      • Animation 动画
      • Transition 过渡
      • Variants 动画状态组
      • Tap 点击
      • Hover 悬浮
      • Pan
      • Drag
      • Types
    • Animation
      • Overview
      • Animation controls
      • Tween
      • Spring
      • Inertia 惯性
      • Orchestration
      • Types
    • Color
      • Create
      • Modify
      • Convert
      • Compare
      • Models
    • Page
      • Content
      • Padding
      • Events
      • Effects
      • PageEffectInfo
    • Scroll
      • Sizing
      • Content
      • Events
    • Stack
      • Content
      • Padding
    • Utilities
      • Transfrom
      • useTransform
      • useAnimation
      • useCycle
      • useMotionValue
      • useSpring
      • useViewportScroll
  • FRAMER X
    • Assets
      • Functions
    • Data & Overrides
    • CanvasComponents
      • Canvas.tsx
      • Layout
      • Colors
    • PropertyControls
      • Adding Controls
      • Hiding Controls
      • Array
      • Boolean
      • Color
      • ComponentInstance
      • Enum
      • File
      • FusedNumber
      • Image
      • Number
      • SegmentedEnum
      • String
    • Render Target
      • Properties
      • Functions
Powered by GitBook
On this page

Was this helpful?

  1. LIBRARY 库
  2. Color

Create

Color(color, r, g, b): Color

Color函数可以用来定义颜色,你既可以直接传颜色的字符串形式的值,也可以传进去一个对象。所有颜色都会被转换成一个颜色对象,r、g、b或者h、s、l及a的格式。有多种颜色格式的参数都可以实现创建一个颜色的对象。

// HEX
const blue = Color("#0099FF")

// RGB
const blue = Color("rgb(0, 153, 255)")
const blue = Color(0, 153, 255)
const blue = Color({r: 0, g: 153, b: 255})
const blue = Color({r: 0, g: 153, b: 255, a: 1})

// HSL
const blue = Color("hsl(204, 100%, 50%)")
const blue = Color({h: 204, s: 1, l: 0.5})
const blue = Color({h: 204, s: 1, l: 0.5, a: 1})

color: IncomingColor | Color | number

r: number

g: number

b: number

returns: Color

Color.random(alphaValue): Color

返回一个颜色对象的实例同时设置了随机的透明度

const random = Color.random()

alphaValue: number

可选的透明度值,默认是1

returns: Color实例

PreviousColorNextModify

Last updated 5 years ago

Was this helpful?