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

Add the use of the size variable. #10

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ to its constructor, although sensible defaults are provided:
- `text` - text to be displayed in the favicon. This can be any unicode characters
including emojis, cyrillic, hangul, etc.
- `font` - font of the text. This can be any valid CSS `font-family` value
- `size` - size of the text. This is in pixels
- `color` - color of the text to be displayed. Can be any valid CSS `color` value
- `background` - color of the marquee's background. Transparent by default. Can be
any valid CSS `color` value
Expand All @@ -71,10 +72,10 @@ marquee is re-rendered.
const marquee = new FaviconMarquee({
text: 'Different text',
color: '#323330',
size: 48,
size: 200,
step: 0.5,
background: "#F0DB4F",
marginBottom: 3,
marginBottom: 32,
});
marquee.start();
```
Expand Down
5 changes: 4 additions & 1 deletion src/canvasPainter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class CanvasPainter {
private readonly stepSize: number;
private readonly font: string;
private readonly marginBottom: number;
private readonly size: number;
private readonly background?: string;
private readonly textWidth: number;

Expand All @@ -21,6 +22,7 @@ export class CanvasPainter {
color = "green",
step = 0.75,
marginBottom = 0,
size = 200,
background,
}: FaviconMarqueeParameters,
renderingContext: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D
Expand All @@ -30,11 +32,12 @@ export class CanvasPainter {
this.stepSize = step;
this.font = font;
this.marginBottom = marginBottom;
this.size = size
this.background = background;

this.pixelsScrolled = 0;
this.renderingContext = renderingContext;
this.renderingContext.font = CANVAS_SIZE + "px " + this.font;
this.renderingContext.font = this.size + "px " + this.font;
this.textWidth = Math.ceil(this.renderingContext.measureText(this.text).width);
}

Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export interface FaviconMarqueeParameters {
* Default: undefined (transparent, color of browser's tab background)
*/
background?: string;
/**
* The size of the text rendered in the favicon. This can be used to make the
* text bigger or smaller.
*/
size?: number;
}

export enum Mode {
Expand Down