Skip to content

Commit

Permalink
Merge pull request #1 from han190/Experimental
Browse files Browse the repository at this point in the history
update the main branch
  • Loading branch information
han190 authored Feb 4, 2023
2 parents 435b53d + cd33f03 commit 9fb3af3
Show file tree
Hide file tree
Showing 44 changed files with 5,973 additions and 5,275 deletions.
70 changes: 49 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,61 @@
# Fortran Logo Refined
<p align="center">
<img src="./data/logo_green_letter.svg" style="width:20%">
<img src="./data/logo_red_rounded.svg" style="width:20%">
<img src="./data/logo_blue_chobby.svg" style="width:20%">
<img src="./data/logo_yellow_regular.svg" style="width:20%">
</p>

## Motivation
<h1 align="center">
Fortran Logo Generator
</h1>

The "F" logo designed by Jacobs William (@jacobwilliams) and Milan Curcic (@milancurcic) is based on the F letter shown on the cover of the original IBM Fortran programmer's reference manual in 1956. The idea is brilliant, but the [logo](https://github.com/fortran-lang/assets) uses Clarendon BT font, which, if you look carefully, is not the font used by the [original reference manual](https://en.wikipedia.org/wiki/Programming_language_reference#/media/File:Fortran_acs_cover.jpeg). Therefore, I did some research and figured out a method to parameterize the "F" letter. Since this is a logo refinement for the Fortran programming language, naturally we want to do everything with Fortran:)
This project has two driving factors:

* To provide a portable and customizable Fortran logo generator written in modern Fortran,
* To polish the current Fortran logo.

## Quick start

The only dependence of the project is gnuplot. To build it
To compile and execute the program, navigate to the project directory and type
```bash
fpm build
fpm run -- --blueprint # to print a blueprint
fpm run -- --logo 300 svg # to print the "F" logo
fpm run # Use default parameters.nml
fpm run -- /your/own/namelist/parameters.nml
```
The program is tested under WSL only but it should also work on all linux/mac. Please report an issue if you spotted one, and pull requests are welcome too!

## Parameterization

<picture>
<source media="(prefers-color-scheme: dark)" srcset="data/blueprint_dark.svg">
<image alt="" width=600 height=600 src="data/blueprint_light.svg" align="center">
</picture>

The whole "F" letter could be parameterized by six parameters:

* `num_curves`, the number of points used when drawing curves.
* `side_length`, the side length of the logo.
* `corner_radius`, the radius of the rounded corner.
* `reference_point`, the reference point for mirroring usage.
* `x`, a 3 x 3 matrix for horizontal coordinates.
* `y`, a 3 x 3 matrix for vertical coordinates.

As shown in the diagram above, these parameters are converted into 18 coordinates (`F1`-`F18`) and a reference point (`R`) for the letter "F" and 12 coordinates for the rounded-corner boundary (`B1`-`B12`). The "F" points can be further categorized into three groups: (1) F1 - F6, (2) F7 - F12, and (3) F13 - F18. The whole logo could be quickly drawn by mirroring group 1 with respect to `RX` and `RY`, and mirroring group 3 with respect to `RX`. Notice that all curves are [quadratic bezier curves](https://en.wikipedia.org/wiki/B%C3%A9zier_curve). The advantage of the parameterization is that, by changing parameters, users could create their own varient of the "F" logo.
<p align="center">
<img width="80%" src="./data/logo_showcase.svg">
</p>

The diagram displays the conversion of horizontal anchors "X" and vertical anchors "Y" into 18 coordinates (labeled 1-18) for the letter "F" and 12 coordinates for the boundary (labeled A-L), referred to as "piles" in the code (represented as empty circles). These 18 coordinates can be separated into three groups: 1-6, 7-12, and 13-18. The logo is easily created by mirroring group 1 with respect to RX and RY and mirroring group 3 with respect to RX. Fine-tuning can be achieved through the "bracket_offset" parameter (referred to as OFFSET in the diagram). Other parameters can be found in the table below.

## Namelist Parameters

| Parameter Name | |
|:-----|:-------|
| `integer :: num_points(2)` | Number of points used to draw (1) curves and (2) smoothed corners |
| `real :: rad_corners` | Radius of smoothed corners (element &#8712; (0, &#x221E;), suggested: < 0.05) |
| `real :: width` | Width of the logo (px) (element &#8712; (0, &#x221E;)) |
| `real :: height` | Height of the logo (px) (element &#8712; (0, &#x221E;)) |
| `real :: margin(4)` | <left, right, bottom, top> margin (px) from letter "F" to the boundary (element &#8712; (0, &#x221E;))|
| `real :: corner(2)` | Radius (px) of the boundary (element &#8712; (0, &#x221E;)) |
| `real :: reference_point(2)` | The reference point (element &#8712; [0, 1]) |
| `real :: bracket_offset(2)` | The bracket offset (element &#8712; [0, 1]) |
| `real :: hori_anchors(3, 3)` | Horizontal anchors (element &#8712; [0, 1]) |
| `real :: vert_anchors(3, 3)` | Vertical anchors (element &#8712; [0, 1]) |
| `character(len=80) :: file` | Ouptut filename |
| `logical :: letter_only` | If `.true.`, draw the letter "F" only, otherwise draw the frame with an empty "F". |
| `real :: canvas_ratio` | canvas ratio = width of canvas/width of boundary (If `width=100`, `height=200`, and `canvas_ratio=1.1`, the actual size of the svg file is 110px x 220px) |
| `character(len=80) :: color` | The color of the logo |
| `character(len=80) :: font_family` | The font of labels (debug) |
| `character(len=80) :: font_size` | The font size of labels (debug) |
| `real :: pile_radius` | Radius of piles (debug) |
| `real :: line_width` | Line width of logo |
| `real :: dash_width` | Line width of dashed lines (debug) |
| `character(len=80) :: dash_array` | Dashed type (debug) |
| `real :: fill_pattern(4)` | Fill pattern |
| `logical :: compare` | Compare with another image (debug) |
| `character(len=80) :: compare_image` | The image to be compared (debug) |
Binary file added data/Clarendon_BT_Roman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/F1954.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9fb3af3

Please sign in to comment.