-
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.
- Loading branch information
Showing
4 changed files
with
286 additions
and
30 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Color } from "../mod.ts"; | ||
import { createCanvas } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
const i = createCanvas(550, 100); | ||
|
||
const ctx = i.getContext("2d"); | ||
ctx.textAlign = "center" | ||
ctx.textBaseline = "middle" | ||
ctx.font = "10px 900 Arial" | ||
|
||
const c = Color.fromHex("#e3242b"); | ||
|
||
for (let i = 0; i < 11; ++i) { | ||
const shade = c.shade(i * 10) | ||
ctx.fillStyle = shade.toString() | ||
ctx.fillRect(i * 50, 0, 50, 50) | ||
|
||
ctx.fillStyle = "white" | ||
ctx.fillText(`${i * 10}%`, i * 50 + 25, 25, 50) | ||
|
||
const tint = c.tint(i * 10) | ||
ctx.fillStyle = tint.toString() | ||
ctx.fillRect(i * 50, 50, 50, 50) | ||
ctx.fillStyle = "black" | ||
ctx.fillText(`${i * 10}%`, i * 50 + 25, 75, 50) | ||
} | ||
|
||
i.save(`examples/shades_and_tints.png`, "png") |
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