Skip to content
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
24 changes: 16 additions & 8 deletions public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 21 additions & 15 deletions public/gpcr-particles.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function initParticleHero(hero) {
for (var i = b.p.length / 7; i < N; i++) {
var d = sph(),
r = 0.9 + R() * 1.1;
b.add(d[0] * r * 1.35, d[1] * r * 0.9, d[2] * r, 4, 0.8, 0.26);
b.add(d[0] * r * 1.35, d[1] * r * 0.9, d[2] * r, 5, 0.8, 0.26);
}
var idx = new Uint32Array(N),
k,
Expand Down Expand Up @@ -127,7 +127,7 @@ export function initParticleHero(hero) {
p[0] + j(0.03),
p[1] + j(0.03),
p[2] + j(0.03),
k ? 0 : 1,
k ? 0 : 3,
1.4,
0.95,
);
Expand All @@ -146,7 +146,7 @@ export function initParticleHero(hero) {
p[0] + (q[0] - p[0]) * u,
p[1] + (q[1] - p[1]) * u,
p[2] + (q[2] - p[2]) * u,
2,
1,
2,
1,
);
Expand Down Expand Up @@ -272,7 +272,7 @@ export function initParticleHero(hero) {
0.03 * sin(x * 3) * cos(z * 2.5) +
j(0.024),
z,
4,
5,
1,
0.5,
);
Expand Down Expand Up @@ -431,7 +431,7 @@ export function initParticleHero(hero) {
A.forEach(function (a) {
var het = a[2] !== "C",
rad = het ? 0.07 : 0.05,
tone = a[2] === "O" ? 2 : a[2] === "N" ? 0 : 3;
tone = a[2] === "O" ? 1 : a[2] === "N" ? 0 : 3;
for (k = per; k--;) {
var d = sph(),
q = rad * Math.pow(R(), 0.3);
Expand Down Expand Up @@ -556,7 +556,7 @@ export function initParticleHero(hero) {

var LV = 8,
col = [],
labelCol = "#17171a",
labelCol = "#1d1d1d",
labelFont = '"IBM Plex Mono",ui-monospace,monospace';
var solid = true;
function hex(value) {
Expand All @@ -568,17 +568,23 @@ export function initParticleHero(hero) {
}
function readColors() {
const style = getComputedStyle(hero);
const tokens = ["--green", "--yellow", "--red", "--blue", "--ink-2"];
const fallback = ["#178553", "#f6c51b", "#d92d1c", "#1e4fc2", "#6a6a70"];
tokens.forEach(function (token, tone) {
const rgb = hex(style.getPropertyValue(token) || fallback[tone]);
const tones = [
["--ku-blue-400", "#103f65"],
["--ku-red", "#901a1e"],
["--ku-green-300", "#446c5a"],
["--ku-teal-300", "#2a7481"],
["--ink-2", "#666666"],
["--ku-green-200", "#b0cabe"],
];
tones.forEach(function ([token, fallback], tone) {
const rgb = hex(style.getPropertyValue(token) || fallback);
col[tone] = Array.from(
{ length: LV },
(_, level) =>
"rgba(" + rgb.join(",") + "," + (level / (LV - 1)).toFixed(3) + ")",
);
});
labelCol = style.getPropertyValue("--ink").trim() || "#17171a";
labelCol = style.getPropertyValue("--ink").trim() || "#1d1d1d";
labelFont = style.getPropertyValue("--f-mono").trim() || labelFont;
}
function resize() {
Expand All @@ -588,7 +594,7 @@ export function initParticleHero(hero) {
W = cv.width = Math.round(bounds.width * DPR);
H = cv.height = Math.round(bounds.height * DPR);
cx = W * 0.5;
cy = H * (cur === 1 ? 0.51 : 0.47);
cy = H * (cur === 1 ? 0.55 : 0.47);
U = sceneScale();
readColors();
solid = true;
Expand All @@ -598,13 +604,13 @@ export function initParticleHero(hero) {
}
function sceneScale() {
return cur === 1
? Math.min(W * 0.43, H * 0.45)
? Math.min(W * 0.48, H * 0.45)
: Math.min(W * 0.36, H * 0.39);
}
/* ---------- render ---------- */
function draw(advance, snap) {
const targetScale = sceneScale();
const targetCenter = H * (cur === 1 ? 0.51 : 0.47);
const targetCenter = H * (cur === 1 ? 0.55 : 0.47);
if (advance) {
U += (targetScale - U) * 0.08;
cy += (targetCenter - cy) * 0.08;
Expand Down Expand Up @@ -702,7 +708,7 @@ export function initParticleHero(hero) {
var al = sh.al[i] * (0.35 + 0.65 * clamp(0.5 - z2 * 0.45)) + bst * 0.6;
var lv = (Math.min(1, al) * (LV - 1) + 0.5) | 0;
if (!lv) continue;
var c = col[sh.tone[i]][lv];
var c = col[cur === 1 && sh.role[i] ? 1 : sh.tone[i]][lv];
if (c !== last) {
ctx.fillStyle = c;
last = c;
Expand Down
32 changes: 1 addition & 31 deletions src/components/Logo.astro
Original file line number Diff line number Diff line change
@@ -1,38 +1,8 @@
---
// Seven tilted bars: the seven helices of a G protein-coupled receptor.
interface Props {
width?: number;
}
const { width = 34 } = Astro.props;
const bars = [
{ fill: "#1E4FC2", angle: -8 },
{ fill: "#F6C51B", angle: 6 },
{ fill: "#D92D1C", angle: -4 },
{ fill: "#178553", angle: 9 },
{ fill: "#1E4FC2", angle: -6 },
{ fill: "#D92D1C", angle: 4 },
{ fill: "#F6C51B", angle: -10 },
];
---

<svg
width={width}
height={(width * 24) / 34}
viewBox="0 0 44 34"
aria-hidden="true"
>
{bars.map((bar, i) => {
const x = 1 + i * 6.3;
return (
<rect
x={x}
y="3"
width="4.5"
height="28"
rx="2.25"
fill={bar.fill}
transform={`rotate(${bar.angle} ${x + 2.25} 17)`}
/>
);
})}
</svg>
<img src="/favicon.svg" width={width} height={width} alt="" />
51 changes: 29 additions & 22 deletions src/components/ParticleReceptor.astro
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ const scenes = ["Genomics", "Structure", "Pharmacology", "Health care"];

<style>
.particle-hero {
width: min(650px, 100%);
width: 100%;
}
.particle-stage {
position: relative;
aspect-ratio: 1.15;
aspect-ratio: 1.4;
/* A circular glow that fades out fully before the edge of the box, so no
rectangle shows against the halftone dots. */
background: radial-gradient(
Expand Down Expand Up @@ -74,15 +74,10 @@ const scenes = ["Genomics", "Structure", "Pharmacology", "Health care"];
visibility: hidden;
touch-action: pan-y;
cursor: crosshair;
/* Fade stray particles out in a circle, so none stop at a straight edge. */
-webkit-mask-image: radial-gradient(
circle closest-side,
#000 72%,
transparent 100%
);
/* Feather only the perimeter; keep the ligand and scene labels legible. */
mask-image: radial-gradient(
circle closest-side,
#000 72%,
ellipse farthest-side,
#000 89%,
transparent 100%
);
}
Expand All @@ -91,7 +86,7 @@ const scenes = ["Genomics", "Structure", "Pharmacology", "Health care"];
justify-content: center;
align-items: center;
gap: 7px;
margin: 4px auto 0;
margin: 8px auto 0;
}
[data-ready="true"] canvas {
visibility: visible;
Expand All @@ -110,11 +105,12 @@ const scenes = ["Genomics", "Structure", "Pharmacology", "Health care"];
background: var(--white);
}
.particle-controls button {
padding: 9px 10px;
min-height: 44px;
padding: 10px 14px;
border: 0;
color: var(--ink);
background: var(--white);
font: 500 11px/1.15 var(--f-mono);
font: 500 12px/1.15 var(--f-mono);
cursor: pointer;
}
.scene-switch button + button {
Expand All @@ -135,7 +131,7 @@ const scenes = ["Genomics", "Structure", "Pharmacology", "Health care"];
display: grid;
place-items: center;
align-self: stretch;
min-width: 31px;
min-width: 44px;
border: 1.5px solid var(--ink);
box-shadow: 2px 2px 0 var(--ink);
}
Expand All @@ -151,25 +147,36 @@ const scenes = ["Genomics", "Structure", "Pharmacology", "Health care"];
border-width: 5px 0 5px 8px;
border-left-color: currentColor;
}
@media (min-width: 1201px) {
.particle-hero {
width: min(650px, 55%);
@media (max-width: 700px) {
.particle-stage {
aspect-ratio: 1.05;
}
}
@media (max-width: 520px) {
.particle-stage {
aspect-ratio: 1.05;
aspect-ratio: 0.85;
}
.particle-controls {
gap: 5px;
}
.particle-controls button {
padding: 9px 5px;
font-size: 10px;
padding-inline: 6px;
font-size: 11px;
}
}
@media (max-width: 390px) {
.scene-switch {
flex-wrap: wrap;
justify-content: center;
display: grid;
grid-template-columns: repeat(2, 1fr);
}
.scene-switch button:nth-child(odd) {
border-left: 0;
}
.scene-switch button:nth-child(n + 3) {
border-top: 1px solid var(--ink);
}
.particle-controls [data-particle-pause] {
align-self: center;
}
}
</style>
34 changes: 17 additions & 17 deletions src/components/Receptor.astro
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
// Cut-paper G protein-coupled receptor: seven helices crossing the membrane,
// a drug arriving from outside. Colors are the four primaries.
// a drug arriving from outside.
const lipidX = Array.from({ length: 25 }, (_, i) => 11 + i * 22);
const helices = [
{ x: 70, angle: -7, fill: "#1E4FC2" },
{ x: 140, angle: 5, fill: "#F6C51B" },
{ x: 210, angle: -3, fill: "#D92D1C" },
{ x: 280, angle: 8, fill: "#178553" },
{ x: 350, angle: -6, fill: "#1E4FC2" },
{ x: 420, angle: 3, fill: "#D92D1C" },
{ x: 490, angle: -9, fill: "#F6C51B" },
{ x: 70, angle: -7, fill: "var(--ku-blue-400)" },
{ x: 140, angle: 5, fill: "var(--ku-teal-300)" },
{ x: 210, angle: -3, fill: "var(--ku-blue-300)" },
{ x: 280, angle: 8, fill: "var(--ku-teal-400)" },
{ x: 350, angle: -6, fill: "var(--ku-blue-400)" },
{ x: 420, angle: 3, fill: "var(--ku-teal-300)" },
{ x: 490, angle: -9, fill: "var(--ku-blue-300)" },
];
const loops = [
"M55 152 C55 100 14 112 22 72 S62 34 40 12",
Expand Down Expand Up @@ -55,7 +55,7 @@ const loops = [
markerHeight="7"
orient="auto-start-reverse"
>
<path d="M0 0 L10 5 L0 10 z" fill="#17171A"></path>
<path d="M0 0 L10 5 L0 10 z" fill="var(--ink)"></path>
</marker>
</defs>

Expand All @@ -64,10 +64,10 @@ const loops = [
y="182"
width="560"
height="166"
fill="#fff"
fill="var(--ku-green-100)"
fill-opacity=".55"
></rect>
<g fill="#fff">
<g fill="var(--ku-green-200)">
{lipidX.map((cx) => (
<circle cx={cx} cy="186" r="8" />
))}
Expand All @@ -76,7 +76,7 @@ const loops = [
))}
</g>

<g fill="none" stroke="#17171A" stroke-width="4.5" stroke-linecap="round">
<g fill="none" stroke="var(--ink)" stroke-width="4.5" stroke-linecap="round">
{loops.map((d) => (
<path d={d} />
))}
Expand Down Expand Up @@ -108,21 +108,21 @@ const loops = [
<path
d="M252 76 C252 110 244 130 250 166"
fill="none"
stroke="#17171A"
stroke="var(--ink)"
stroke-width="2"
stroke-dasharray="5 6"
marker-end="url(#head)"
></path>
<g transform="translate(236 38) rotate(-14)" filter="url(#cut)">
<polygon
points="0,-20 17.3,-10 17.3,10 0,20 -17.3,10 -17.3,-10"
fill="#17171A"
fill="var(--ku-red)"
></polygon>
<rect x="16" y="-3.5" width="18" height="7" fill="#17171A"></rect>
<rect x="16" y="-3.5" width="18" height="7" fill="var(--ku-red)"></rect>
<polygon
points="46,-13 58.4,-4 53.7,10.5 38.3,10.5 33.6,-4"
fill="#17171A"
fill="var(--ku-red)"
></polygon>
<circle cx="17.3" cy="10" r="5.5" fill="#D92D1C"></circle>
<circle cx="17.3" cy="10" r="5.5" fill="var(--ku-green-100)"></circle>
</g>
</svg>
Loading