-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from monooso/6-radius-bug
Fix radius bug
- Loading branch information
Showing
6 changed files
with
43 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
# Contributing | ||
Thank you for thinking about contributing to this project. This document will help you to get started. | ||
|
||
Thank you for thinking about contributing to this project. This document will | ||
help you to get started. | ||
|
||
## Adding a feature | ||
If you'd like to add a feature to Avatar (or modify its existing behaviour), please start by [creating an issue][create_issue] so we can discuss it. | ||
Don't go straight to a pull request in case it's something I don't wish to accept; I don't want to waste your time. | ||
|
||
If you'd like to add a feature to Avatar (or modify its existing behaviour), | ||
please start by [creating an issue][create_issue] so we can discuss it. Don't go | ||
straight to a pull request in case it's something I don't wish to accept; I | ||
don't want to waste your time. | ||
|
||
## Fixing a bug | ||
If you've found a bug, please start by [creating an issue][create_issue]. If you'd like to [make a pull request][create_pr] for the fix once I've confirmed it's a bug in Avatar, that would be great. | ||
|
||
If you've found a bug, please start by [creating an issue][create_issue]. If | ||
you'd like to [make a pull request][create_pr] for the fix once I've confirmed | ||
it's a bug in Avatar, that would be great. | ||
|
||
[create_issue]: https://github.com/monooso/avatar/issues/new | ||
[create_pr]: https://github.com/monooso/avatar/compare | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,7 @@ avatars based on usernames or ids. | |
## Usage | ||
|
||
```typescript | ||
import { | ||
generatePng, | ||
generateSvg, | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { generatePng, generateSvg } from "https://deno.land/x/avatar/mod.ts"; | ||
|
||
// Generate an SVG avatar with the default options. | ||
let avatar = await generateSvg("jimbob"); | ||
|
@@ -31,6 +28,7 @@ avatar = await generatePng("cleetus", { radius: 20, size: 256 }); | |
``` | ||
|
||
## License | ||
|
||
Avatar is open source software, released under [the MIT license](./LICENSE.txt). | ||
|
||
## Credits | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import { z } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
const defaults = { radius: 0, size: 64 }; | ||
|
||
const validator = z.object({ | ||
radius: z.number().int().min(0).default(0), | ||
size: z.number().int().min(1).default(64), | ||
radius: z.number().int().min(0).default(defaults.radius), | ||
size: z.number().int().min(1).default(defaults.size), | ||
}); | ||
|
||
type Options = z.input<typeof validator>; | ||
type InputOptions = z.input<typeof validator>; | ||
type OutputOptions = z.output<typeof validator>; | ||
|
||
/** | ||
* Validates and normalizes the given options. Raises if validation fails. | ||
*/ | ||
function validate(opts: Options): Options { | ||
function validate(opts: InputOptions): OutputOptions { | ||
return validator.parse(opts); | ||
} | ||
|
||
export { validate }; | ||
export type { Options }; | ||
export { defaults, validate }; | ||
export type { InputOptions, OutputOptions }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters