Skip to content

Commit

Permalink
Add attributions for rendered images
Browse files Browse the repository at this point in the history
  • Loading branch information
banga committed Feb 3, 2024
1 parent 036efa5 commit e5aa4e5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 6 deletions.
1 change: 1 addition & 0 deletions posts/2024-02-02-learning-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ I picked up the [Programming Rust, 2nd Edition](https://www.oreilly.com/library/
Around this time, I left my job and took a complete break from programming. Then around the end of 2023, after I did [Advent of Code](https://adventofcode.com/) in Rust, I got a second wind and started reading the book again. As I learned things I could use in the raytracer, I would go back and [apply](https://github.com/banga/craytracer/commit/9ff0d0498ad5524cd5ae4c2e16d4dcb47980a9a8) [them](https://github.com/banga/craytracer/commit/e31a0249d15c1c614d61d7b11ed83350b7accf0f) [to](https://github.com/banga/craytracer/commit/6b92724ebc8740685312d92c3d67bebda5ccabc7) it. I eventually once again got distracted by the graphics and added several sophisticated features to get to the point of rendering images like this:

![A raytraced image of a staircase with textures, area lighting](/assets/staircase.png)
_[The Wooden Staircase](https://blendswap.com/blend/14449) by [Wig42](https://blendswap.com/profile/130393)_

Anyway, I did finish the book once the raytracing side quest was done (for now). While there are a few chapters that will need a revisit when I actually need to use them (Async, FFI, unsafe rust), I ended it feeling a lot more comfortable with the language.

Expand Down
2 changes: 2 additions & 0 deletions src/components/Img.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import React from "react";

export function Img({
src,
node,
...rest
}: {
src?: string | undefined;
node?: import("hast").Element | undefined;
className?: string | undefined;
alt?: string | undefined;
width?: string | number | undefined;
Expand Down
45 changes: 39 additions & 6 deletions src/pages/ProjectsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,20 @@ function Project({
);
}

function Screenshot({ src }: { src: string }) {
function Screenshot({
src,
caption: caption,
}: {
src: string;
caption?: ReactNode;
}) {
return (
<Link className="flex-row pt1 pb1" href={src}>
<Img src={src} />
</Link>
<div className="flex-col pt1 pb1 align-center">
<Link href={src}>
<Img src={src} />
</Link>
{caption && <em>{caption}</em>}
</div>
);
}

Expand Down Expand Up @@ -137,8 +146,32 @@ function Projects() {
>
A physically based raytracer in rust. Some sample images:
<div className="flex-row">
<Screenshot src="/assets/staircase.png" />
<Screenshot src="/assets/helmet.png" />
<Screenshot
src="/assets/staircase.png"
caption={
<>
<Link href="https://blendswap.com/blend/14449">
The Wooden Staircase
</Link>{" "}
by{" "}
<Link href="https://blendswap.com/profile/130393">Wig42</Link>
</>
}
/>
<Screenshot
src="/assets/helmet.png"
caption={
<>
<Link href="https://www.blendswap.com/blend/13953">
Stormtrooper
</Link>{" "}
by{" "}
<Link href="https://www.blendswap.com/profile/120125">
Scott Graham
</Link>
</>
}
/>
</div>
Started it to learn rust, but admittedly got carried away while reading{" "}
<Link href="https://pbrt.org/">pbrt</Link> and implemented a{" "}
Expand Down
10 changes: 10 additions & 0 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ pre > pre {
img {
max-width: 100%;
height: auto;

/* Center images in posts */
display: block;
margin: 0 auto;
}

/* Hack to support image captions */
img + em {
display: block;
text-align: center;
}

.photo {
Expand Down

0 comments on commit e5aa4e5

Please sign in to comment.