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

refactor: unify default strokeColor for outline shapes #1169

Merged
merged 5 commits into from Jun 5, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/renderer/AttrHelper.ts
Expand Up @@ -290,6 +290,7 @@ export const attrStroke = (
"stroke-dasharray",
properties.strokeDasharray.contents
);
attrMapped.push("strokeDasharray");
} else if (
"strokeStyle" in properties &&
properties.strokeStyle.contents === "dashed"
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/shapes/Line.ts
@@ -1,8 +1,8 @@
import * as ad from "../types/ad.js";
import { Arrow, Named, ShapeCommon, Stroke } from "../types/shapes.js";
import { StrV, VectorV } from "../types/value.js";
import { boolV, floatV, strV } from "../utils/Util.js";
import { Canvas, Context, sampleColor, sampleVector } from "./Samplers.js";
import { black, boolV, floatV, strV } from "../utils/Util.js";
import { Canvas, Context, sampleVector } from "./Samplers.js";

export interface LineProps<T> extends Named<T>, Stroke<T>, Arrow<T> {
start: VectorV<T>;
Expand All @@ -18,7 +18,7 @@ export const sampleLine = (
style: strV(""),
strokeWidth: floatV(1),
strokeStyle: strV("solid"),
strokeColor: sampleColor(context),
strokeColor: black(),
strokeDasharray: strV(""),
startArrowheadSize: floatV(1),
startArrowhead: strV("none"),
Expand Down
13 changes: 10 additions & 3 deletions packages/core/src/shapes/Path.ts
@@ -1,8 +1,15 @@
import * as ad from "../types/ad.js";
import { Arrow, Fill, Named, ShapeCommon, Stroke } from "../types/shapes.js";
import { PathDataV } from "../types/value.js";
import { boolV, floatV, noPaint, pathDataV, strV } from "../utils/Util.js";
import { Canvas, Context, sampleColor } from "./Samplers.js";
import {
black,
boolV,
floatV,
noPaint,
pathDataV,
strV,
} from "../utils/Util.js";
import { Canvas, Context } from "./Samplers.js";

export interface PathProps<T> extends Named<T>, Stroke<T>, Fill<T>, Arrow<T> {
d: PathDataV<T>;
Expand All @@ -16,7 +23,7 @@ export const samplePath = (
style: strV(""),
strokeWidth: floatV(1),
strokeStyle: strV("solid"),
strokeColor: sampleColor(context),
strokeColor: black(),
strokeDasharray: strV(""),
fillColor: noPaint(),
startArrowheadSize: floatV(1),
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/shapes/Text.ts
Expand Up @@ -10,8 +10,8 @@ import {
Stroke,
} from "../types/shapes.js";
import { FloatV, StrV } from "../types/value.js";
import { boolV, floatV, noPaint, strV, vectorV } from "../utils/Util.js";
import { Canvas, Context, sampleColor, uniform } from "./Samplers.js";
import { black, boolV, floatV, noPaint, strV, vectorV } from "../utils/Util.js";
import { Canvas, Context, uniform } from "./Samplers.js";

export interface TextProps<T>
extends Named<T>,
Expand Down Expand Up @@ -47,7 +47,7 @@ export const sampleText = (
strokeStyle: strV("solid"),
strokeColor: noPaint(),
strokeDasharray: strV(""),
fillColor: sampleColor(context),
fillColor: black(),
center: vectorV([
context.makeInput({
init: { tag: "Sampled", sampler: uniform(...canvas.xRange) },
Expand Down
2 changes: 2 additions & 0 deletions packages/examples/src/curve-examples/cubic-bezier.style
Expand Up @@ -5,6 +5,7 @@ canvas {

global {
scalar t = 0.4
color semiBlue = rgba( 27./255., 31./255., 138./255., .2 )
}

forall Curve c {
Expand All @@ -17,6 +18,7 @@ forall Curve c {
shape curve = Path {
d: cubicCurveFromPoints("open", points)
strokeWidth: 3.5
strokeColor: global.semiBlue
ensureOnCanvas: true
}

Expand Down
5 changes: 5 additions & 0 deletions packages/examples/src/fake-3d-linear-algebra/fake3d.style
Expand Up @@ -62,6 +62,7 @@ where VectorInHyperplane(v, P, S) {
ensure inRange(v.vec[1], -2, 2)
ensure equal(v.vec[2], 0)
ensure equal(dot(v.vec, P.normal_vector), 0)
v.shape above P.shape
}

forall Vector v; Hyperplane P; AmbientSpace S
Expand All @@ -84,12 +85,16 @@ where w := addV(u, v); VectorInAmbientSpace(u, S); VectorInAmbientSpace(v, S); V
start: v.shape.end
end: w.shape.end
strokeStyle : "dashed"
strokeColor: #70707080
strokeWidth : .01
strokeDasharray: "0.07,0.05"
}
w.dashed_v = Line {
start: u.shape.end
end: w.shape.end
strokeStyle : "dashed"
strokeColor: #70707080
strokeWidth : .01
strokeDasharray: "0.07,0.05"
}
}
Expand Up @@ -2,5 +2,5 @@
"substance": "./projection.substance",
"style": ["./fake3d.style"],
"domain": "./fake3d.domain",
"variation": "PurpletiniSeahorse9761"
"variation": "SucculentsReindeer397"
}