mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-08 07:28:11 +08:00
Add Poisson-disk sampling node and Bezier-rs 0.4 release (#1586)
* Add Poisson-disk sampling node and Bezier-rs 0.4 release * Additional optimizations * More performance optimizations with help from 0Hypercube * Add comments
This commit is contained in:
@@ -409,7 +409,7 @@ const bezierFeatures = {
|
||||
})(),
|
||||
},
|
||||
"intersect-linear": {
|
||||
name: "Intersect (Line Segment)",
|
||||
name: "Intersect (Linear Segment)",
|
||||
callback: (bezier: WasmBezierInstance): string => {
|
||||
const line = [
|
||||
[45, 30],
|
||||
@@ -419,7 +419,7 @@ const bezierFeatures = {
|
||||
},
|
||||
},
|
||||
"intersect-quadratic": {
|
||||
name: "Intersect (Quadratic)",
|
||||
name: "Intersect (Quadratic Segment)",
|
||||
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string => {
|
||||
const quadratic = [
|
||||
[45, 80],
|
||||
@@ -435,7 +435,7 @@ const bezierFeatures = {
|
||||
},
|
||||
},
|
||||
"intersect-cubic": {
|
||||
name: "Intersect (Cubic)",
|
||||
name: "Intersect (Cubic Segment)",
|
||||
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string => {
|
||||
const cubic = [
|
||||
[65, 20],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { capOptions, joinOptions, tSliderOptions, subpathTValueVariantOptions, intersectionErrorOptions, minimumSeparationOptions } from "@/utils/options";
|
||||
import { capOptions, joinOptions, tSliderOptions, subpathTValueVariantOptions, intersectionErrorOptions, minimumSeparationOptions, separationDiskDiameter } from "@/utils/options";
|
||||
import type { SubpathCallback, SubpathInputOption, WasmSubpathInstance } from "@/utils/types";
|
||||
import { SUBPATH_T_VALUE_VARIANTS } from "@/utils/types";
|
||||
|
||||
@@ -59,12 +59,17 @@ const subpathFeatures = {
|
||||
name: "Bounding Box",
|
||||
callback: (subpath: WasmSubpathInstance): string => subpath.bounding_box(),
|
||||
},
|
||||
"poisson-disk-points": {
|
||||
name: "Poisson-Disk Points",
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>, _: undefined): string => subpath.poisson_disk_points(options.separation_disk_diameter),
|
||||
inputOptions: [separationDiskDiameter],
|
||||
},
|
||||
inflections: {
|
||||
name: "Inflections",
|
||||
callback: (subpath: WasmSubpathInstance): string => subpath.inflections(),
|
||||
},
|
||||
"intersect-linear": {
|
||||
name: "Intersect (Line Segment)",
|
||||
name: "Intersect (Linear Segment)",
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>): string =>
|
||||
subpath.intersect_line_segment(
|
||||
[
|
||||
@@ -105,11 +110,24 @@ const subpathFeatures = {
|
||||
),
|
||||
inputOptions: [intersectionErrorOptions, minimumSeparationOptions],
|
||||
},
|
||||
"self-intersect": {
|
||||
name: "Self Intersect",
|
||||
"intersect-self": {
|
||||
name: "Intersect (Self)",
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>): string => subpath.self_intersections(options.error, options.minimum_separation),
|
||||
inputOptions: [intersectionErrorOptions, minimumSeparationOptions],
|
||||
},
|
||||
"intersect-rectangle": {
|
||||
name: "Intersect (Rectangle)",
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>): string =>
|
||||
subpath.intersect_rectangle(
|
||||
[
|
||||
[75, 50],
|
||||
[175, 150],
|
||||
],
|
||||
options.error,
|
||||
options.minimum_separation,
|
||||
),
|
||||
inputOptions: [intersectionErrorOptions, minimumSeparationOptions],
|
||||
},
|
||||
curvature: {
|
||||
name: "Curvature",
|
||||
callback: (subpath: WasmSubpathInstance, options: Record<string, number>, _: undefined): string => subpath.curvature(options.t, SUBPATH_T_VALUE_VARIANTS[options.TVariant]),
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { BEZIER_T_VALUE_VARIANTS, CAP_VARIANTS, JOIN_VARIANTS, SUBPATH_T_VALUE_VARIANTS } from "@/utils/types";
|
||||
|
||||
export const tSliderOptions = {
|
||||
variable: "t",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
default: 0.5,
|
||||
variable: "t",
|
||||
};
|
||||
|
||||
export const errorOptions = {
|
||||
@@ -32,6 +32,14 @@ export const intersectionErrorOptions = {
|
||||
default: 0.02,
|
||||
};
|
||||
|
||||
export const separationDiskDiameter = {
|
||||
variable: "separation_disk_diameter",
|
||||
min: 2.5,
|
||||
max: 25,
|
||||
step: 0.1,
|
||||
default: 5,
|
||||
};
|
||||
|
||||
export const bezierTValueVariantOptions = {
|
||||
variable: "TVariant",
|
||||
default: 0,
|
||||
|
||||
Reference in New Issue
Block a user