-
-
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
Showing
84 changed files
with
15,224 additions
and
212 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -13,5 +13,10 @@ | |
"devDependencies": { | ||
"wsrun": "^5.2.4" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@radix-ui/react-popover": "latest", | ||
"@radix-ui/react-scroll-area": "^1.0.3", | ||
"react-draggable-tree": "^0.7.0" | ||
} | ||
} |
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
Empty file.
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,7 @@ | ||
export type InkSetting<T extends Record<string, any> | null = {}> = { | ||
inkId: string | ||
inkVersion: string | ||
|
||
/** Ink specific settings */ | ||
specific: T | ||
} |
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 @@ | ||
export { CircleBrush } from './CircleBrush' |
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,35 @@ | ||
import { ColorRGBA } from '@/Document' | ||
import { VectorPathPoint } from '@/Document/LayerEntity/VectorPath' | ||
import { Camera, WebGLRenderer } from 'three' | ||
|
||
export interface InkClass { | ||
readonly id: string | ||
readonly version: string | ||
|
||
new (): IInk | ||
} | ||
|
||
export interface IInk { | ||
class: InkClass | ||
|
||
initialize(): Promise<void> | void | ||
getInkGenerator(ctx: any): InkGenerator | ||
} | ||
|
||
export interface InkGenerator { | ||
getColor(inkContext: { | ||
pointIndex: number | ||
points: VectorPathPoint[] | ||
pointAtLength: number | ||
totalLength: number | ||
baseColor: ColorRGBA | ||
}): ColorRGBA | ||
|
||
applyTexture( | ||
canvas: CanvasRenderingContext2D, | ||
context: { | ||
threeRenderer: WebGLRenderer | ||
threeCamera: Camera | ||
} | ||
): void | ||
} |
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,39 @@ | ||
import { Emitter } from '@/utils/Emitter' | ||
import { IInk, InkClass } from './Ink' | ||
|
||
type Events = { | ||
entriesChanged: void | ||
} | ||
|
||
export class InkRegistry extends Emitter<Events> { | ||
protected brushes: Map<string, InkClass> = new Map() | ||
protected instances: WeakMap<InkClass, IInk> = new WeakMap() | ||
|
||
public async register(Brush: InkClass) { | ||
try { | ||
this.brushes.set(Brush.id, Brush) | ||
|
||
const brush = new Brush() | ||
await brush.initialize() | ||
|
||
this.instances.set(Brush, brush) | ||
} catch (e) { | ||
this.brushes.delete(Brush.id) | ||
this.instances.delete(Brush) | ||
throw e | ||
} | ||
|
||
this.emit('entriesChanged') | ||
} | ||
|
||
public get brushEntries(): InkClass[] { | ||
return [...this.brushes.values()] | ||
} | ||
|
||
public getInstance(id: string): IInk | null { | ||
const Class = this.brushes.get(id) | ||
if (!Class) return null | ||
|
||
return this.instances.get(Class) ?? null | ||
} | ||
} |
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,23 @@ | ||
import { IInk, InkGenerator } from '../Ink' | ||
|
||
export class PlainInk implements IInk { | ||
public static id = '@paplico/core/ink/plain' | ||
public static version = '0.0.1' | ||
|
||
public get class() { | ||
return PlainInk | ||
} | ||
|
||
public initialize() {} | ||
|
||
getInkGenerator(ctx: any): InkGenerator { | ||
return { | ||
applyTexture(canvas, context) { | ||
return | ||
}, | ||
getColor({ pointIndex, points, baseColor }) { | ||
return baseColor | ||
}, | ||
} | ||
} | ||
} |
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,33 @@ | ||
import { createSeededRandom } from '@/Math' | ||
import { IInk, InkGenerator } from '../Ink' | ||
|
||
export class RainbowInk implements IInk { | ||
public static id = '@paplico/core/ink/rainbow' | ||
public static version = '0.0.1' | ||
|
||
public get class() { | ||
return RainbowInk | ||
} | ||
|
||
public initialize() {} | ||
|
||
getInkGenerator(ctx: any): InkGenerator { | ||
return { | ||
applyTexture(canvas, context) { | ||
return | ||
}, | ||
getColor({ pointIndex, points, baseColor }) { | ||
const random = createSeededRandom(pointIndex) | ||
|
||
return baseColor | ||
|
||
return { | ||
r: random.nextFloat(), | ||
g: random.nextFloat(), | ||
b: random.nextFloat(), | ||
a: baseColor.a, | ||
} | ||
}, | ||
} | ||
} | ||
} |
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.