mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-08 23:48:12 +08:00
Bezier-rs: Add joins and caps to offsets and outlines (#1083)
* Intial work * Improve miter and add round join * Get arcs to go opposite direction * Add cap and other refactors * Rename joint to join, fix some bugs * Fix single point issue * Clean up * Fix iframe sizes and update UI * Address comments and handle single point outline * Rename variables, fix branches in outline * Address comments
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { WasmBezier } from "@graphite/../wasm/pkg";
|
||||
import { tSliderOptions, bezierTValueVariantOptions, errorOptions, minimumSeparationOptions } from "@graphite/utils/options";
|
||||
import { capOptions, tSliderOptions, bezierTValueVariantOptions, errorOptions, minimumSeparationOptions } from "@graphite/utils/options";
|
||||
import { BezierDemoOptions, WasmBezierInstance, BezierCallback, InputOption, BEZIER_T_VALUE_VARIANTS } from "@graphite/utils/types";
|
||||
|
||||
const bezierFeatures = {
|
||||
@@ -251,7 +251,7 @@ const bezierFeatures = {
|
||||
},
|
||||
outline: {
|
||||
name: "Outline",
|
||||
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string => bezier.outline(options.distance),
|
||||
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string => bezier.outline(options.distance, options.cap),
|
||||
demoOptions: {
|
||||
Quadratic: {
|
||||
inputOptions: [
|
||||
@@ -262,13 +262,14 @@ const bezierFeatures = {
|
||||
step: 1,
|
||||
default: 15,
|
||||
},
|
||||
capOptions,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"graduated-outline": {
|
||||
name: "Graduated Outline",
|
||||
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string => bezier.graduated_outline(options.start_distance, options.end_distance),
|
||||
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string => bezier.graduated_outline(options.start_distance, options.end_distance, options.cap),
|
||||
demoOptions: {
|
||||
Quadratic: {
|
||||
inputOptions: [
|
||||
@@ -286,6 +287,7 @@ const bezierFeatures = {
|
||||
step: 1,
|
||||
default: 15,
|
||||
},
|
||||
capOptions,
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -300,7 +302,8 @@ const bezierFeatures = {
|
||||
},
|
||||
"skewed-outline": {
|
||||
name: "Skewed Outline",
|
||||
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string => bezier.skewed_outline(options.distance1, options.distance2, options.distance3, options.distance4),
|
||||
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string =>
|
||||
bezier.skewed_outline(options.distance1, options.distance2, options.distance3, options.distance4, options.cap),
|
||||
demoOptions: {
|
||||
Quadratic: {
|
||||
inputOptions: [
|
||||
@@ -332,6 +335,7 @@ const bezierFeatures = {
|
||||
step: 1,
|
||||
default: 5,
|
||||
},
|
||||
capOptions,
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tSliderOptions, subpathTValueVariantOptions, intersectionErrorOptions, minimumSeparationOptions } from "@graphite/utils/options";
|
||||
import { InputOption, SubpathCallback, WasmSubpathInstance, SUBPATH_T_VALUE_VARIANTS } from "@graphite/utils/types";
|
||||
import { capOptions, joinOptions, tSliderOptions, subpathTValueVariantOptions, intersectionErrorOptions, minimumSeparationOptions } from "@graphite/utils/options";
|
||||
import { SubpathCallback, SubpathInputOption, WasmSubpathInstance, SUBPATH_T_VALUE_VARIANTS } from "@graphite/utils/types";
|
||||
|
||||
const subpathFeatures = {
|
||||
constructor: {
|
||||
@@ -107,7 +107,7 @@ const subpathFeatures = {
|
||||
},
|
||||
offset: {
|
||||
name: "Offset",
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>): string => subpath.offset(options.distance),
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>): string => subpath.offset(options.distance, options.join),
|
||||
inputOptions: [
|
||||
{
|
||||
variable: "distance",
|
||||
@@ -116,11 +116,12 @@ const subpathFeatures = {
|
||||
step: 1,
|
||||
default: 10,
|
||||
},
|
||||
joinOptions,
|
||||
],
|
||||
},
|
||||
outline: {
|
||||
name: "Outline",
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>): string => subpath.outline(options.distance),
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>): string => subpath.outline(options.distance, options.join, options.cap),
|
||||
inputOptions: [
|
||||
{
|
||||
variable: "distance",
|
||||
@@ -129,6 +130,8 @@ const subpathFeatures = {
|
||||
step: 1,
|
||||
default: 10,
|
||||
},
|
||||
joinOptions,
|
||||
{ ...capOptions, isDisabledForClosed: true },
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -137,7 +140,7 @@ export type SubpathFeatureKey = keyof typeof subpathFeatures;
|
||||
export type SubpathFeatureOptions = {
|
||||
name: string;
|
||||
callback: SubpathCallback;
|
||||
inputOptions?: InputOption[];
|
||||
inputOptions?: SubpathInputOption[];
|
||||
triggerOnMouseMove?: boolean;
|
||||
};
|
||||
export default subpathFeatures as Record<SubpathFeatureKey, SubpathFeatureOptions>;
|
||||
|
||||
Reference in New Issue
Block a user