Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: implement dash offset for custom line styles #211

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/klighd-core/src/views-rendering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* http://rtsys.informatik.uni-kiel.de/kieler
*
* Copyright 2019-2024 by
* Copyright 2019-2025 by
* + Kiel University
* + Department of Computer Science
* + Real-Time and Embedded Systems Group
Expand Down Expand Up @@ -909,6 +909,7 @@ export function renderSingleSVGRect(
...(kShadow ? {} : { 'stroke-linejoin': lineStyles.lineJoin }),
...(kShadow ? {} : { 'stroke-width': lineStyles.lineWidth }),
...(kShadow ? {} : { 'stroke-dasharray': lineStyles.dashArray }),
...(kShadow ? {} : { 'stroke-dashoffset': lineStyles.dashOffset }),
...(kShadow ? {} : { 'stroke-miterlimit': lineStyles.miterLimit }),
opacity: kShadow
? colorStyles.opacity
Expand Down Expand Up @@ -1110,6 +1111,7 @@ export function renderSingleSVGArc(
...(kShadow ? {} : { 'stroke-linejoin': lineStyles.lineJoin }),
...(kShadow ? {} : { 'stroke-width': lineStyles.lineWidth }),
...(kShadow ? {} : { 'stroke-dasharray': lineStyles.dashArray }),
...(kShadow ? {} : { 'stroke-dashoffset': lineStyles.dashOffset }),
...(kShadow ? {} : { 'stroke-miterlimit': lineStyles.miterLimit }),
opacity: kShadow
? colorStyles.opacity
Expand Down Expand Up @@ -1186,6 +1188,7 @@ export function renderSingleSVGEllipse(
...(kShadow ? {} : { 'stroke-linejoin': lineStyles.lineJoin }),
...(kShadow ? {} : { 'stroke-width': lineStyles.lineWidth }),
...(kShadow ? {} : { 'stroke-dasharray': lineStyles.dashArray }),
...(kShadow ? {} : { 'stroke-dashoffset': lineStyles.dashOffset }),
...(kShadow ? {} : { 'stroke-miterlimit': lineStyles.miterLimit }),
opacity: kShadow
? colorStyles.opacity
Expand Down Expand Up @@ -1256,6 +1259,7 @@ export function renderSingleSVGLine(
...(kShadow ? {} : { 'stroke-linejoin': lineStyles.lineJoin }),
...(kShadow ? {} : { 'stroke-width': lineStyles.lineWidth }),
...(kShadow ? {} : { 'stroke-dasharray': lineStyles.dashArray }),
...(kShadow ? {} : { 'stroke-dashoffset': lineStyles.dashOffset }),
...(kShadow ? {} : { 'stroke-miterlimit': lineStyles.miterLimit }),
opacity: kShadow
? colorStyles.opacity
Expand Down
4 changes: 3 additions & 1 deletion packages/klighd-core/src/views-styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* http://rtsys.informatik.uni-kiel.de/kieler
*
* Copyright 2019-2023 by
* Copyright 2019-2025 by
* + Kiel University
* + Department of Computer Science
* + Real-Time and Embedded Systems Group
Expand Down Expand Up @@ -866,6 +866,7 @@ export function getSvgLineStyles(styles: KStyles, target: SKGraphElement, contex
lineCap: lineCap === DEFAULT_LINE_CAP_SVG ? undefined : lineCap,
lineJoin: lineJoin === DEFAULT_LINE_JOIN_SVG ? undefined : lineJoin,
dashArray: styles.kLineStyle === undefined ? undefined : lineStyleText(styles.kLineStyle, lineWidth),
dashOffset: styles.kLineStyle === undefined ? undefined : styles.kLineStyle.dashOffset?.toString(),
// Note: Here the miter limit value is also omitted if the value equals KGraph's default value of 10, because otherwise the resulting SVG would
// always contain the miterLimit style to be set to 10, even though it is not intended by the creator of the KGraph model and it would not
// even make any difference in the rendering. Here I cannot distinguish if the model creator really wanted to have the specific miter limit of 10
Expand Down Expand Up @@ -941,6 +942,7 @@ export interface LineStyles {
lineCap: 'butt' | 'round' | 'square' | undefined
lineJoin: 'bevel' | 'miter' | 'round' | undefined
dashArray: string | undefined
dashOffset: string | undefined
miterLimit: string | undefined
}

Expand Down
Loading