Skip to content

Commit

Permalink
Rebranding
Browse files Browse the repository at this point in the history
  • Loading branch information
imikailoby committed Aug 19, 2024
1 parent e61fd2f commit c7bb6ff
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# @imikailoby/mariflag

[International Maritime Signal Flags](https://en.wikipedia.org/wiki/International_maritime_signal_flags) SVG generator.
Mariflag is a versatile SVG generator that converts text sequences into a series of icons. While originally inspired by
[maritime signal flags](https://en.wikipedia.org/wiki/International_maritime_signal_flags), this package also allows you
to provide your own custom SVG icons for each letter, enabling you to encode text into various visual forms, limited only
by your imagination (and the available SVG icons of course).

For example, you can create visualizations inspired by [semaphore signals](https://en.wikipedia.org/wiki/Optical_telegraph),
encode text into designs similar to [Morse code](https://en.wikipedia.org/wiki/Morse_code)
or [Braille](https://en.wikipedia.org/wiki/Braille), and more.

![example](https://github.com/user-attachments/assets/20b56f3f-658a-4d05-9ab9-cadfae31677f)<svg xmlns="http://www.w3.org/2000/svg" width="496px" height="48px"><svg><g transform="translate(0, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)"><path fill="#002BFD" d="M0 0h48v48H0z"></path><path fill="#fff" d="m-5.108-10.764 63.872 63.872-5.657 5.657-63.872-63.873z"></path><path fill="#fff" d="M58.765-5.108-5.107 58.764l-5.657-5.656 63.872-63.873z"></path><path stroke="#000" d="M.5.5h47v47H.5z"></path></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h48v48H0z"></path></clipPath></defs></svg></g></svg><svg><g transform="translate(64, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#fff" d="M0 0h24v48H0z"></path><path d="M24 0h24L36 24l12 24H24V0Z" fill="#002CFF"></path><mask id="a" fill="#fff"><path fill-rule="evenodd" clip-rule="evenodd" d="M24 0H0v48h48L36 24 48 0H24Z"></path></mask><path d="M0 0v-1h-1v1h1Zm0 48h-1v1h1v-1Zm48 0v1h1.618l-.724-1.447L48 48ZM36 24l-.894-.447-.224.447.224.447L36 24ZM48 0l.894.447L49.618-1H48v1ZM0 1h24v-2H0v2Zm1 47V0h-2v48h2Zm23-1H0v2h24v-2Zm24 0H24v2h24v-2ZM35.106 24.447l12 24 1.788-.894-12-24-1.788.894Zm12-24.894-12 24 1.788.894 12-24-1.788-.894ZM24 1h24v-2H24v2Z" fill="#000" mask="url(#a)"></path></svg></g></svg><svg><g transform="translate(128, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#FF1000" d="M48 0v48H0V0z"></path><path fill="#FFFC00" d="M18 48V0h12v48z"></path><path fill="#FFFC00" d="M0 18h48v12H0z"></path><path stroke="#000" d="M.5.5h47v47H.5z"></path></svg></g></svg><svg><g transform="translate(192, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#FFFC00" d="M0 0h48v48H0z"></path><path stroke="#000" d="M.5.5h47v47H.5z"></path><circle cx="24" cy="24" r="12" fill="#000"></circle></svg></g></svg><svg><g transform="translate(256, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#fff" d="M0 0h48v48H0z"></path><path fill="#FF1000" d="m24 0 24 24-24 24L0 24z"></path><path stroke="#000" d="M.5.5h47v47H.5z"></path></svg></g></svg><svg><g transform="translate(320, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#FFFC00" d="M48 0v48H0V0z"></path><path stroke="#000" d="M.5.5h47v47H.5z"></path><path fill="#000" d="M48 0v24H24V0zM24 24v24H0V24z"></path></svg></g></svg><svg><g transform="translate(384, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#fff" d="M0 0h24v48H0z"></path><path d="M24 0h24L36 24l12 24H24V0Z" fill="#002CFF"></path><mask id="a" fill="#fff"><path fill-rule="evenodd" clip-rule="evenodd" d="M24 0H0v48h48L36 24 48 0H24Z"></path></mask><path d="M0 0v-1h-1v1h1Zm0 48h-1v1h1v-1Zm48 0v1h1.618l-.724-1.447L48 48ZM36 24l-.894-.447-.224.447.224.447L36 24ZM48 0l.894.447L49.618-1H48v1ZM0 1h24v-2H0v2Zm1 47V0h-2v48h2Zm23-1H0v2h24v-2Zm24 0H24v2h24v-2ZM35.106 24.447l12 24 1.788-.894-12-24-1.788.894Zm12-24.894-12 24 1.788.894 12-24-1.788-.894ZM24 1h24v-2H24v2Z" fill="#000" mask="url(#a)"></path></svg></g></svg><svg><g transform="translate(448, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#FFFC00" d="M8 0v48H0V0zM24 0v48h-8V0zM40 0v48h-8V0z"></path><path fill="#002BFD" d="M16 0v48H8V0zM32 0v48h-8V0zM48 0v48h-8V0z"></path><path stroke="#000" d="M.5.5h47v47H.5z"></path></svg></g></svg></svg>

Expand All @@ -16,16 +23,16 @@ npm install @imikailoby/mariflag

## Usage

1. Import the `generateMarineCode` function into your project.
1. Import the `generateSvg` function into your project.
2. Provide the necessary string input **(only A-Z characters are supported)** and configuration _(optional)_.
3. ... and you're done!

Example:

```ts
import { generateMarineCode } from '@imikailoby/mariflag'; // Import the main function
import { generateSvg } from '@imikailoby/mariflag'; // Import the main function

const helloSvg = generateMarineCode('Hello'); // Provide the required text
const helloSvg = generateSvg('Hello'); // Provide the required text

// ... Use the generated SVG as needed.
```
Expand All @@ -35,7 +42,7 @@ const helloSvg = generateMarineCode('Hello'); // Provide the required text
Provide a custom configuration as a second argument to override the default parameters. Example:

```ts
generateMarineCode("string", {
generateSvg("string", {
orientation: "horizontal",
offset: 16,
customIcons: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@imikailoby/mariflag",
"version": "1.2.0",
"description": "International Maritime Signal Flags SVG generator",
"description": "Versatile SVG Generator for Custom Icon Sequences. Inspired by International Maritime Signal Flags",
"author": "Mikhail Prosmitskiy",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { generateMarineCode } from './utils/generateMarineCode';
export { generateSvg } from './utils/generateSvg';
export type { MarineCodeConfig } from './types/config';
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { generateMarineCode } from './generateMarineCode';
import { generateSvg } from './generateSvg';

describe('generateMarineCode()', () => {
describe('generateSvg()', () => {
it('returns an empty string if the input is empty', () => {
expect(generateMarineCode('')).toBe('');
expect(generateSvg('')).toBe('');
});

it('returns a correct SVG string for a given input with a default configuration', () => {
expect(generateMarineCode('abc')).toBe(
expect(generateSvg('abc')).toBe(
'<svg xmlns="http://www.w3.org/2000/svg" width="176px" height="48px"><g transform="translate(0, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#fff" d="M0 0h24v48H0z"/><path d="M24 0h24L36 24l12 24H24V0Z" fill="#002CFF"/><mask id="a" fill="#fff"><path fill-rule="evenodd" clip-rule="evenodd" d="M24 0H0v48h48L36 24 48 0H24Z"/></mask><path d="M0 0v-1h-1v1h1Zm0 48h-1v1h1v-1Zm48 0v1h1.618l-.724-1.447L48 48ZM36 24l-.894-.447-.224.447.224.447L36 24ZM48 0l.894.447L49.618-1H48v1ZM0 1h24v-2H0v2Zm1 47V0h-2v48h2Zm23-1H0v2h24v-2Zm24 0H24v2h24v-2ZM35.106 24.447l12 24 1.788-.894-12-24-1.788.894Zm12-24.894-12 24 1.788.894 12-24-1.788-.894ZM24 1h24v-2H24v2Z" fill="#000" mask="url(#a)"/></svg></g><g transform="translate(64, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#FF1000" d="M0 0h24v48H0zM24 0h24L36 24l12 24H24V0Z"/><mask id="a" fill="#fff"><path fill-rule="evenodd" clip-rule="evenodd" d="M24 0H0v48h48L36 24 48 0H24Z"/></mask><path d="M0 0v-1h-1v1h1Zm0 48h-1v1h1v-1Zm48 0v1h1.618l-.724-1.447L48 48ZM36 24l-.894-.447-.224.447.224.447L36 24ZM48 0l.894.447L49.618-1H48v1ZM0 1h24v-2H0v2Zm1 47V0h-2v48h2Zm23-1H0v2h24v-2Zm24 0H24v2h24v-2ZM35.106 24.447l12 24 1.788-.894-12-24-1.788.894Zm12-24.894-12 24 1.788.894 12-24-1.788-.894ZM24 1h24v-2H24v2Z" fill="#000" mask="url(#a)"/></svg></g><g transform="translate(128, 0)"><svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#002CFF" d="M0 0h48v12H0z"/><path fill="#fff" d="M0 12h48v8H0zM0 28h48v8H0z"/><path fill="#FF1000" d="M0 20h48v8H0z"/><path fill="#002BFD" d="M0 36h48v12H0z"/><path stroke="#000" d="M.5.5h47v47H.5z"/></svg></g></svg>',
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getSvgArrayFromName } from './getSvgArrayFromName';
import { normalizeConfig } from './normalizeConfig';
import { prepareString } from './prepareString';

export function generateMarineCode(text: string, config?: MarineCodeConfig): string {
export function generateSvg(text: string, config?: MarineCodeConfig): string {
const preparedString = prepareString(text);
if (!preparedString) return '';

Expand Down

0 comments on commit c7bb6ff

Please sign in to comment.