diff --git a/README.md b/README.md index ce6aec3..80c23ca 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ Fork of [rough-notation](https://github.com/rough-stuff/rough-notation) Changes in this fork: -- Expose config and data types +- Expose types - Support custom `class` option +- Support custom `opacity` option for strokes - Support passing through all options to RoughJS for full customization - Support `getConfig` and `setConfig` methods - Improved build assets with `.cjs` and `.mjs` diff --git a/src/render.ts b/src/render.ts index d525620..a2d4188 100644 --- a/src/render.ts +++ b/src/render.ts @@ -225,6 +225,8 @@ export function renderAnnotation( setAttr(path, 'fill', 'none') setAttr(path, 'stroke', config.color || 'currentColor') setAttr(path, 'stroke-width', `${strokeWidth}`) + if (config.opacity !== undefined) + setAttr(path, 'style', `opacity:${config.opacity}`) if (animate) { const length = path.getTotalLength() lengths.push(length) diff --git a/src/types.ts b/src/types.ts index a19846c..174ba66 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,13 +12,13 @@ export type FullPadding = [number, number, number, number] export type RoughPadding = number | [number, number] | FullPadding export type BracketType = 'left' | 'right' | 'top' | 'bottom' -export interface RoughAnnotationConfig extends RoughAnnotationConfigBase { +export interface RoughAnnotationConfig extends RoughAnnotationConfigBase, Partial { type: RoughAnnotationType multiline?: boolean rtl?: boolean } -export interface RoughAnnotationConfigBase extends Partial { +export interface RoughAnnotationConfigBase { animate?: boolean // defaults to true animationDuration?: number // defaults to 1000ms color?: string // defaults to currentColor @@ -27,6 +27,7 @@ export interface RoughAnnotationConfigBase extends Partial { iterations?: number // defaults to 2 brackets?: BracketType | BracketType[] // defaults to 'right' delay?: number // defaults to 0 + opacity?: number // defaults to 1 /** * Additional class to add to the root SVG element */