共通の型
View のプロパティ、データ型、コード例を確認できます。
ViewContent
View、基本値、入れ子配列の描画内容。null/undefined は内容なし。
type ViewContent =
View | string | number | boolean | null | undefined | ViewContent[];
例
const example: ViewContent = ['Speed', 78, null];
TextContent
toString() で文字列化。null/undefined は空。アイコンは別の View と組み合わせます。
type TextContent =
| string
| number
| bigint
| boolean
| symbol
| { toString(): string }
| null
| undefined;
例
const example: TextContent = {
toString() {
return '78 km/h';
},
};
HDRColor
描画色やグラデーションに使う HDR 色データ。
type HDRColor = { readonly $type: 'CapDrive.HDR'; readonly color: string };
例
const example: HDRColor = HDR('white');
RGBColor
r/g/b と任意の a は 0–1。space は srgb または displayP3。
type RGBColor = {
space?: 'srgb' | 'displayP3';
r: number;
g: number;
b: number;
a?: number;
};
例
const example: RGBColor = {
space: 'displayP3',
r: 0.2,
g: 0.7,
b: 0.6,
a: 0.8,
};
Color
色名、16進文字列、RGBColor または HDR() の色。
type Color = string | RGBColor | HDRColor;
例
const example: Color = '#30B3A2';
ViewPoint
画面ポイント単位のローカル x/y。緯度経度ではありません。
type ViewPoint = { x: number; y: number };
例
const example: ViewPoint = { x: 20, y: 40 };
ChartDataPoint
value.x/y は座標、label.x/y は表示文字。y が null なら線を分断。
type ChartDataPoint = {
value: { x: number; y: number | null };
label: { x: string; y: string };
};
例
const example: ChartDataPoint = {
value: { x: 12, y: null },
label: { x: '12s', y: '' },
};
ChartRange
数値範囲 [min, max]。項目の番号やラベルではありません。
type ChartRange = readonly [min: number, max: number];
例
const example: ChartRange = [-20, 100];
MapCoordinate
緯度 latitude と経度 longitude(度)。
type MapCoordinate = { latitude: number; longitude: number };
例
const example: MapCoordinate = { latitude: 31.2304, longitude: 121.4737 };
MapPathStyle
ネイティブ経路スタイル:Color、幅、端、結合、破線、外枠、任意の始終点マーカー。グラデーション非対応。
type MapPathStyle = {
stroke?: Color;
lineWidth?: number;
lineCap?: 'round' | 'butt' | 'square';
lineJoin?: 'round' | 'miter' | 'bevel';
dash?: readonly number[];
dashPhase?: number;
outlineStroke?: Color;
outlineWidth?: number;
showEndpoints?: boolean;
};
例
const example: MapPathStyle = {
stroke: '#30B3A2',
lineWidth: 4,
outlineStroke: 'white',
outlineWidth: 1,
showEndpoints: true,
};
ChartAxisStyle
軸の色・線幅・線端・破線。clear で軸線を隠し、ラベルは別に制御。
type ChartAxisStyle = {
stroke?: Paint;
lineWidth?: number;
lineCap?: 'round' | 'butt' | 'square';
dash?: readonly number[];
dashPhase?: number;
};
例
const example: ChartAxisStyle = {
stroke: '#888888',
lineWidth: 1,
dash: [4, 3],
};
BarChartDataPoint
棒 1 本の value と任意の label。配列順に配置。
type BarChartDataPoint = { value: number; label?: string };
例
const example: BarChartDataPoint = { value: -25, label: 'B' };
PathCommand
move、line、quad、cubic、arc、close の命令。座標と半径はポイント、角度は度。
type PathCommand =
| { op: 'move'; x: number; y: number }
| { op: 'line'; x: number; y: number }
| { op: 'quad'; x: number; y: number; cx: number; cy: number }
| {
op: 'cubic';
x: number;
y: number;
c1x: number;
c1y: number;
c2x: number;
c2y: number;
}
| {
op: 'arc';
x: number;
y: number;
radius: number;
startAngle: number;
sweepAngle: number;
}
| { op: 'close' };
例
const example: PathCommand = {
op: 'cubic',
x: 100,
y: 60,
c1x: 20,
c1y: 0,
c2x: 80,
c2y: 100,
};
GradientStop
色、または色と 0–1 の location を持つ色標。
type GradientStop = Color | { color: Color; location: number };
例
const example: GradientStop = { color: '#30B3A2', location: 0.7 };
GradientColors
順序付きの色/色標。色のみなら等間隔。
type GradientColors = ReadonlyArray<GradientStop>;
例
const example: GradientColors = [
{ color: 'red', location: 0 },
{ color: 'blue', location: 1 },
];
LinearGradientOptions
線形グラデーションの angle(度)と正規化 center。中央は (0.5, 0.5)。
type LinearGradientOptions = { angle?: number; center?: ViewPoint };
例
const example: LinearGradientOptions = {
angle: 90,
center: { x: 0.5, y: 0.5 },
};
RadialGradientOptions
放射状グラデーションの startRadius/endRadius(ポイント)と正規化 center。
type RadialGradientOptions = {
startRadius?: number;
endRadius?: number;
center?: ViewPoint;
};
例
const example: RadialGradientOptions = {
startRadius: 0,
endRadius: 60,
center: { x: 0.5, y: 0.5 },
};
AngularGradientOptions
角度グラデーションの angle(度)と正規化 center。
type AngularGradientOptions = { angle?: number; center?: ViewPoint };
例
const example: AngularGradientOptions = {
angle: -90,
center: { x: 0.5, y: 0.5 },
};
Gradient
LinearGradient、RadialGradient、AngularGradient が作る塗り。new の有無は任意。
type Gradient = {
readonly type: 'linear' | 'radial' | 'angular';
readonly angle?: number;
readonly startRadius?: number;
readonly endRadius?: number;
readonly center?: ViewPoint;
readonly colors: GradientColors;
};
例
const example: Gradient = LinearGradient(['red', 'blue'], { angle: 90 });
Paint
描画用の Color または Gradient。
type Paint = Color | Gradient;
例
const example: Paint = RadialGradient(['white', '#30B3A2'], {
endRadius: 60,
});
DrawingEffect
効果の色、不透明度、ぼかし半径、x/y オフセット。距離はポイント。
type DrawingEffect = {
color?: Color;
opacity?: number;
radius?: number;
x?: number;
y?: number;
};
例
const example: DrawingEffect = {
color: 'cyan',
opacity: 0.6,
radius: 8,
x: 0,
y: 2,
};
ViewTransform
レイアウトを変えず全体を変形。移動はポイント、回転・傾きは度、倍率 1 は等倍、基点は 0–1。
type ViewTransform = {
translateX?: number;
translateY?: number;
scaleX?: number;
scaleY?: number;
rotation?: number;
skewX?: number;
skewY?: number;
anchorX?: number;
anchorY?: number;
};
例
const example: ViewTransform = {
rotation: 30,
scaleX: 1.2,
scaleY: 1.2,
anchorX: 0.5,
anchorY: 0.5,
};
RepeatAxisValue
数値なら有効な軸に適用。x/y オブジェクトなら個別指定。
type RepeatAxisValue = number | { x?: number; y?: number };
例
const example: RepeatAxisValue = { x: 120, y: 80 };
AnimationProperty
アニメーション対象の属性名や入れ子パス。View ごとに対応範囲が異なります。
type AnimationProperty =
| 'width'
| 'height'
| 'padding'
| 'x'
| 'y'
| 'opacity'
| 'cornerRadius'
| 'blur'
| 'shadowOpacity'
| 'shadowRadius'
| 'shadowX'
| 'shadowY'
| 'fontSize'
| 'letterSpacing'
| 'minimumScaleFactor'
| 'spacing'
| 'radius'
| 'radiusX'
| 'radiusY'
| 'startAngle'
| 'sweepAngle'
| 'lineWidth'
| 'dashPhase'
| 'trimStart'
| 'trimEnd'
| 'barThickness'
| 'value'
| 'offset'
| 'anchor'
| 'period'
| 'minLength'
| 'color'
| 'stroke'
| 'background'
| 'shadowColor'
| 'transform.translateX'
| 'transform.translateY'
| 'transform.scaleX'
| 'transform.scaleY'
| 'transform.rotation'
| 'transform.skewX'
| 'transform.skewY'
| 'transform.anchorX'
| 'transform.anchorY'
| 'period.x'
| 'period.y'
| 'value.x'
| 'value.y'
| 'anchor.x'
| 'anchor.y'
| 'offset.x'
| 'offset.y'
| 'start.x'
| 'start.y'
| 'end.x'
| 'end.y'
| 'rangeX.0'
| 'rangeX.1'
| 'rangeY.0'
| 'rangeY.1'
| 'xAxis.lineWidth'
| 'xAxis.dashPhase'
| 'yAxis.lineWidth'
| 'yAxis.dashPhase'
| 'xAxis.stroke'
| 'yAxis.stroke'
| 'regionOffset.x'
| 'regionOffset.y'
| 'pathStyle.lineWidth'
| 'pathStyle.outlineWidth'
| 'pathStyle.dashPhase'
| 'pathStyle.stroke'
| 'pathStyle.outlineStroke';
例
const example: AnimationProperty = 'transform.rotation';
Animation
プロパティ変更のアニメーション。duration/delay は秒、from/to は端点、repeat/autoreverse は反復、wrap は周期。
type Animation = {
property: AnimationProperty;
duration?: number;
delay?: number;
curve?: string;
from?: number | Color;
to?: number | Color;
repeat?: number | 'forever';
autoreverse?: boolean;
wrap?: number;
};
例
const example: Animation = {
property: 'opacity',
duration: 0.25,
curve: 'easeOut',
};
CircleAnimation
円弧のアニメーション。sweepAngle は wrap 非対応。startAngle は wrap: 360 が可能。
type CircleAnimation =
| (Omit<Animation, 'property'> & {
property:
| 'width'
| 'height'
| 'x'
| 'y'
| 'opacity'
| 'background'
| 'blur'
| 'shadowColor'
| 'shadowOpacity'
| 'shadowRadius'
| 'shadowX'
| 'shadowY'
| 'dashPhase'
| 'stroke'
| 'lineWidth'
| 'startAngle'
| 'transform.translateX'
| 'transform.translateY'
| 'transform.scaleX'
| 'transform.scaleY'
| 'transform.rotation'
| 'transform.skewX'
| 'transform.skewY'
| 'transform.anchorX'
| 'transform.anchorY';
})
| (Omit<Animation, 'property' | 'wrap' | 'from' | 'to'> & {
property: 'sweepAngle';
from?: number;
to?: number;
wrap?: never;
});
例
const example: CircleAnimation = {
property: 'sweepAngle',
duration: 0.3,
from: 0,
to: 270,
};
EllipseAnimation
円弧のアニメーション。sweepAngle は wrap 非対応。startAngle は wrap: 360 が可能。
type EllipseAnimation =
| (Omit<Animation, 'property'> & {
property:
| 'width'
| 'height'
| 'x'
| 'y'
| 'opacity'
| 'background'
| 'blur'
| 'shadowColor'
| 'shadowOpacity'
| 'shadowRadius'
| 'shadowX'
| 'shadowY'
| 'dashPhase'
| 'stroke'
| 'lineWidth'
| 'startAngle'
| 'transform.translateX'
| 'transform.translateY'
| 'transform.scaleX'
| 'transform.scaleY'
| 'transform.rotation'
| 'transform.skewX'
| 'transform.skewY'
| 'transform.anchorX'
| 'transform.anchorY';
})
| (Omit<Animation, 'property' | 'wrap' | 'from' | 'to'> & {
property: 'sweepAngle';
from?: number;
to?: number;
wrap?: never;
});
例
const example: EllipseAnimation = {
property: 'startAngle',
duration: 0.3,
wrap: 360,
};
ArcAnimation
円弧のアニメーション。sweepAngle は wrap 非対応。startAngle は wrap: 360 が可能。
type ArcAnimation =
| (Omit<Animation, 'property'> & {
property:
| 'width'
| 'height'
| 'x'
| 'y'
| 'opacity'
| 'background'
| 'blur'
| 'shadowColor'
| 'shadowOpacity'
| 'shadowRadius'
| 'shadowX'
| 'shadowY'
| 'dashPhase'
| 'stroke'
| 'lineWidth'
| 'startAngle'
| 'transform.translateX'
| 'transform.translateY'
| 'transform.scaleX'
| 'transform.scaleY'
| 'transform.rotation'
| 'transform.skewX'
| 'transform.skewY'
| 'transform.anchorX'
| 'transform.anchorY';
})
| (Omit<Animation, 'property' | 'wrap' | 'from' | 'to'> & {
property: 'sweepAngle';
from?: number;
to?: number;
wrap?: never;
});
例
const example: ArcAnimation = {
property: 'sweepAngle',
duration: 0.3,
from: 0,
to: -180,
};
MapAnimation
地図 View と経路スタイルの対応属性を動かします。カメラは cameraAnimation で別に制御。
type MapAnimation =
| (Omit<Animation, 'property' | 'from' | 'to'> & {
property:
| 'width'
| 'height'
| 'x'
| 'y'
| 'opacity'
| 'cornerRadius'
| 'transform.translateX'
| 'transform.translateY'
| 'transform.scaleX'
| 'transform.scaleY'
| 'transform.rotation'
| 'transform.skewX'
| 'transform.skewY'
| 'transform.anchorX'
| 'transform.anchorY'
| 'regionOffset.x'
| 'regionOffset.y'
| 'pathStyle.lineWidth'
| 'pathStyle.outlineWidth'
| 'pathStyle.dashPhase';
from?: number;
to?: number;
})
| (Omit<Animation, 'property' | 'from' | 'to' | 'wrap'> & {
property: 'pathStyle.stroke' | 'pathStyle.outlineStroke';
from?: Color;
to?: Color;
wrap?: never;
});
例
const example: MapAnimation = {
property: 'pathStyle.stroke',
duration: 0.25,
from: 'red',
to: 'blue',
};
LineChartAnimation
グラフの範囲と軸線も対象。範囲に wrap は不可、色のパスには色を指定。
type LineChartAnimation =
| (Omit<Animation, 'property'> & {
property:
| 'width'
| 'height'
| 'x'
| 'y'
| 'opacity'
| 'blur'
| 'shadowColor'
| 'shadowOpacity'
| 'shadowRadius'
| 'shadowX'
| 'shadowY'
| 'stroke'
| 'lineWidth'
| 'dashPhase'
| 'transform.translateX'
| 'transform.translateY'
| 'transform.scaleX'
| 'transform.scaleY'
| 'transform.rotation'
| 'transform.skewX'
| 'transform.skewY'
| 'transform.anchorX'
| 'transform.anchorY';
})
| (Omit<Animation, 'property' | 'wrap' | 'from' | 'to'> & {
property: 'rangeX.0' | 'rangeX.1' | 'rangeY.0' | 'rangeY.1';
from?: number;
to?: number;
wrap?: never;
})
| (Omit<Animation, 'property' | 'from' | 'to'> & {
property:
| 'xAxis.lineWidth'
| 'xAxis.dashPhase'
| 'yAxis.lineWidth'
| 'yAxis.dashPhase';
from?: number;
to?: number;
})
| (Omit<Animation, 'property' | 'from' | 'to' | 'wrap'> & {
property: 'xAxis.stroke' | 'yAxis.stroke';
from?: Color;
to?: Color;
wrap?: never;
});
例
const example: LineChartAnimation = { property: 'rangeX.1', duration: 0.25 };
BarChartAnimation
グラフの範囲と軸線も対象。範囲に wrap は不可、色のパスには色を指定。
type BarChartAnimation =
| (Omit<Animation, 'property'> & {
property:
| 'width'
| 'height'
| 'x'
| 'y'
| 'opacity'
| 'background'
| 'cornerRadius'
| 'blur'
| 'shadowColor'
| 'shadowOpacity'
| 'shadowRadius'
| 'shadowX'
| 'shadowY'
| 'barThickness'
| 'stroke'
| 'lineWidth'
| 'dashPhase'
| 'transform.translateX'
| 'transform.translateY'
| 'transform.scaleX'
| 'transform.scaleY'
| 'transform.rotation'
| 'transform.skewX'
| 'transform.skewY'
| 'transform.anchorX'
| 'transform.anchorY';
})
| (Omit<Animation, 'property' | 'wrap' | 'from' | 'to'> & {
property: 'rangeY.0' | 'rangeY.1';
from?: number;
to?: number;
wrap?: never;
})
| (Omit<Animation, 'property' | 'from' | 'to'> & {
property:
| 'xAxis.lineWidth'
| 'xAxis.dashPhase'
| 'yAxis.lineWidth'
| 'yAxis.dashPhase';
from?: number;
to?: number;
})
| (Omit<Animation, 'property' | 'from' | 'to' | 'wrap'> & {
property: 'xAxis.stroke' | 'yAxis.stroke';
from?: Color;
to?: Color;
wrap?: never;
});
例
const example: BarChartAnimation = { property: 'rangeY.1', duration: 0.25 };
RadialLayoutAnimation
円弧のアニメーション。sweepAngle は wrap 非対応。startAngle は wrap: 360 が可能。
type RadialLayoutAnimation =
| (Omit<Animation, 'property'> & {
property:
| 'width'
| 'height'
| 'padding'
| 'x'
| 'y'
| 'opacity'
| 'background'
| 'cornerRadius'
| 'blur'
| 'shadowColor'
| 'shadowOpacity'
| 'shadowRadius'
| 'shadowX'
| 'shadowY'
| 'radius'
| 'radiusX'
| 'radiusY'
| 'startAngle'
| 'transform.translateX'
| 'transform.translateY'
| 'transform.scaleX'
| 'transform.scaleY'
| 'transform.rotation'
| 'transform.skewX'
| 'transform.skewY'
| 'transform.anchorX'
| 'transform.anchorY';
})
| (Omit<Animation, 'property' | 'wrap' | 'from' | 'to'> & {
property: 'sweepAngle';
from?: number;
to?: number;
wrap?: never;
});
例
const example: RadialLayoutAnimation = {
property: 'startAngle',
duration: 0.25,
wrap: 360,
};
SpacerAnimation
Spacer は width、height、minLength の配置のみをアニメーション化。
type SpacerAnimation = {
property: 'width' | 'height' | 'minLength';
duration?: number;
delay?: number;
curve?: string;
from?: number;
to?: number;
repeat?: number | 'forever';
autoreverse?: boolean;
wrap?: number;
};
例
const example: SpacerAnimation = {
property: 'minLength',
duration: 0.25,
from: 8,
to: 24,
};
ContentAnimation
内容変更時の効果。この View 対応の type を選び、duration/delay は秒で指定。
type ContentAnimation = {
type: 'fade' | 'slide' | 'scale' | 'numericText' | 'interpolate';
duration?: number;
delay?: number;
curve?: string;
direction?: string;
distance?: number;
scale?: number;
};
例
const example: ContentAnimation = { type: 'numericText', duration: 0.18 };
ViewSize
測定された width と height(画面ポイント)。
type ViewSize = { width: number; height: number };
例
const example: ViewSize = { width: 240, height: 140 };
ViewInsets
top、leading、bottom、trailing の余白(ポイント)。
type ViewInsets = {
top: number;
leading: number;
bottom: number;
trailing: number;
};
例
const example: ViewInsets = {
top: 24,
leading: 12,
bottom: 12,
trailing: 12,
};
CardContentMetrics
renderer に渡す size、contentSize、headerSize、safeInsets。見出しを避けて本文を配置します。
type CardContentMetrics = {
size: ViewSize;
contentSize: ViewSize;
headerSize: ViewSize;
safeInsets: ViewInsets;
};
例
const example: CardContentMetrics = {
size: { width: 240, height: 160 },
contentSize: { width: 216, height: 124 },
headerSize: { width: 216, height: 24 },
safeInsets: { top: 24, leading: 12, bottom: 12, trailing: 12 },
};