-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55361ec
commit 459da6d
Showing
16 changed files
with
315 additions
and
136 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts" context="module"> | ||
export enum ColorPaletteToolTab { | ||
ColorPicker, | ||
PalettePicker | ||
} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import { dbInstance } from "$lib/rxdb/database" | ||
import type { ColorPalette, ColorPalettes } from "$lib/types/color-palette" | ||
import { onMount } from "svelte" | ||
let palettes: ColorPalettes = [] | ||
let currentPalette: ColorPalette | undefined | ||
onMount(async () => { | ||
const query = dbInstance.colorPalette.find() | ||
palettes = await query.exec() | ||
query.$.subscribe(changes => { | ||
palettes = changes | ||
}) | ||
}) | ||
</script> | ||
|
||
<div class="color-palette-panel"> | ||
</div> | ||
|
||
<style> | ||
.color-palette-panel { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { System } from "$lib/ecs/abstracts" | ||
import { CanvasPointComponent } from "$lib/ecs/components/canvas-point" | ||
import { RasterizedImageComponent } from "$lib/ecs/components/rasterized-image" | ||
import type { Entity } from "$lib/ecs/entity" | ||
import { ToolboxTool, ToolboxToolBase } from "$lib/types/toolbox" | ||
|
||
export class PointerTool extends ToolboxToolBase implements System { | ||
constructor() { | ||
super() | ||
this.type = ToolboxTool.PointerTool | ||
this.name = "Pointer" | ||
this.icon = "pointer" | ||
this.description = "Select elements" | ||
this.tutorial = "Move the cursor over an element and click/tap to select it." | ||
} | ||
|
||
update(entity: Entity): void { | ||
const position = entity.getComponent(CanvasPointComponent) | ||
const icon = entity.getComponent(RasterizedImageComponent) | ||
|
||
if (!position) { | ||
console.warn("Couldn't get position for rectangle selection.") | ||
return | ||
} | ||
|
||
if (!icon) { | ||
console.warn("Didn't find an icon for the cursor.") | ||
return | ||
} | ||
|
||
icon!.point = position!.point! | ||
} | ||
|
||
accepts(component: IComponent): boolean { | ||
return match(component) | ||
.with(P.instanceOf(RasterizedImageComponent), () => true) | ||
.with(P.instanceOf(CanvasPointComponent), () => true) | ||
.otherwise(() => false) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { System } from "$lib/ecs/abstracts" | ||
import { CanvasPointComponent } from "$lib/ecs/components/canvas-point" | ||
import type { Vector } from "$lib/ecs/components/drawings" | ||
import type { Entity } from "$lib/ecs/entity" | ||
import { ToolboxTool, ToolboxToolBase } from "$lib/types/toolbox" | ||
|
||
export class RectangleSelection extends ToolboxToolBase implements System { | ||
start?: Vector | ||
end?: Vector | ||
|
||
constructor(start?: Vector) { | ||
super() | ||
this.type = ToolboxTool.RectangleSelection | ||
this.name = "Rectangle Selection" | ||
this.icon = "rectangle" | ||
this.description = "Select a rectangle on the canvas." | ||
this.tutorial = "Click and drag to create a rectangle." | ||
|
||
this.start = start | ||
} | ||
|
||
update(entity: Entity): void { | ||
const position = entity.getComponent(CanvasPointComponent) | ||
|
||
if (!position) { | ||
console.warn("Couldn't get position for rectangle selection.") | ||
} | ||
|
||
console.log(position) | ||
} | ||
|
||
accepts(component: IComponent): boolean { | ||
return match(component) | ||
.with(P.instanceOf(CanvasPointComponent), () => true) | ||
.otherwise(() => false) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { type RxCollection, type RxJsonSchema } from "rxdb" | ||
import type { ColorPalette as ColorPaletteType } from "$lib/types/color-palette" | ||
|
||
const ColorPalette: RxJsonSchema<ColorPaletteType> = { | ||
version: 0, | ||
title: "color_palette", | ||
description: "Application config.", | ||
primaryKey: "id", | ||
type: "object", | ||
keyCompression: true, | ||
required: ["id", "name", "colors"], | ||
properties: { | ||
id: { | ||
type: "string", | ||
maxLength: 255, | ||
}, | ||
name: { | ||
type: "string", | ||
}, | ||
colors: { | ||
type: "array", | ||
items: { | ||
type: "object", | ||
properties: { | ||
x: { | ||
type: "string", | ||
}, | ||
y: { | ||
type: "string", | ||
}, | ||
z: { | ||
type: "string", | ||
}, | ||
}, | ||
required: ["x", "y", "z"], | ||
additionalProperties: false, | ||
} | ||
}, | ||
}, | ||
} as const | ||
|
||
type ColorPaletteCollection = RxCollection<ColorPaletteType> | ||
|
||
export { ColorPalette, type ColorPaletteCollection } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Vector } from "$lib/ecs/components/drawings" | ||
|
||
interface ColorPalette { | ||
id: string | ||
name?: string | ||
colors: Vector[] | ||
} | ||
|
||
type ColorPalettes = ColorPalette[] | ||
|
||
export { | ||
type ColorPalette, | ||
type ColorPalettes, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.