Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Adjustable camera size (#89)

Brendan Allan0c3bd65b8595
diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
index 64151b3ba..f5849c3a6 100644
--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx
+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
@@ -427,6 +427,15 @@ export function ConfigSidebar() {
</div>
</div>
</Field>
+ <Field name="Size" icon={<IconCapEnlarge />}>
+ <Slider
+ value={[project.camera.size ?? 30]}
+ onChange={(v) => setProject("camera", "size", v[0])}
+ minValue={20}
+ maxValue={80}
+ step={0.1}
+ />
+ </Field>
<Field name="Rounded Corners" icon={<IconCapCorners />}>
<Slider
value={[project.camera.rounding]}
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index 0a9a052fc..8c1ba8021 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -293,7 +293,7 @@ export type AuthStore = { token: string; expires: number }
export type BackgroundConfiguration = { source: BackgroundSource; blur: number; padding: number; rounding: number; inset: number; crop: Crop | null }
export type BackgroundSource = { type: "wallpaper"; id: number } | { type: "image"; path: string | null } | { type: "color"; value: [number, number, number] } | { type: "gradient"; from: [number, number, number]; to: [number, number, number]; angle?: number }
export type Bounds = { x: number; y: number; width: number; height: number }
-export type CameraConfiguration = { hide: boolean; mirror: boolean; position: CameraPosition; rounding: number; shadow: number }
+export type CameraConfiguration = { hide: boolean; mirror: boolean; position: CameraPosition; rounding: number; shadow: number; size?: number }
export type CameraMeta = { path: string }
export type CameraPosition = { x: CameraXPosition; y: CameraYPosition }
export type CameraXPosition = "left" | "center" | "right"
diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rs
index f69a467d6..dbc4919ee 100644
--- a/crates/project/src/configuration.rs
+++ b/crates/project/src/configuration.rs
@@ -109,6 +109,15 @@ pub struct CameraConfiguration {
pub position: CameraPosition,
pub rounding: f32,
pub shadow: u32,
+ // min 20 max 80
+ #[serde(default = "CameraConfiguration::default_size")]
+ pub size: f32,
+}
+
+impl CameraConfiguration {
+ fn default_size() -> f32 {
+ 30.0
+ }
}
#[derive(Type, Serialize, Deserialize, Clone, Debug, Default)]
diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs
index 6bab71fab..df37b305f 100644
--- a/crates/rendering/src/lib.rs
+++ b/crates/rendering/src/lib.rs
@@ -228,7 +228,6 @@ pub struct ProjectUniforms {
}
const CAMERA_PADDING: f32 = 50.0;
-const CAMERA_UV_WIDTH: f32 = 0.3;
const SCREEN_MAX_PADDING: f32 = 0.4;
@@ -362,8 +361,8 @@ impl ProjectUniforms {
let min_axis = output_size[0].min(output_size[1]);
let size = [
- min_axis * CAMERA_UV_WIDTH + CAMERA_PADDING,
- min_axis * CAMERA_UV_WIDTH + CAMERA_PADDING,
+ min_axis * project.camera.size / 100.0 + CAMERA_PADDING,
+ min_axis * project.camera.size / 100.0 + CAMERA_PADDING,
];
let position = {