-
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.
Support custom transformations for the abstract driver. (#100)
- Loading branch information
Showing
8 changed files
with
106 additions
and
41 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,3 +1,5 @@ | ||
/build/ | ||
out/ | ||
.packages/ | ||
*.swp | ||
*.swo | ||
.packages |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
sdk: ^2.0.0-alpha.121 | ||
sdk: ^2.0.0-alpha.144 | ||
prefixes: | ||
png-tools: toit-png-tools | ||
packages: | ||
|
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
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,38 @@ | ||
// Copyright (C) 2024 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the TESTS_LICENSE file. | ||
import bitmap show * | ||
import font show Font | ||
import pixel-display show * | ||
import pixel-display.two-color show BLACK WHITE | ||
import .png-visualizer | ||
|
||
class TransformedDriver extends TwoColorPngVisualizer: | ||
constructor width/int height/int path/string --outline/int?=null: | ||
super width height path --outline=outline | ||
|
||
base-transform --inverted/bool --portrait/bool? -> Transform: | ||
// Simulate a display that wants its input rotated 90 degrees and inverted. | ||
if portrait == null: | ||
portrait = true | ||
else: | ||
portrait = not portrait | ||
return super --no-inverted --portrait=portrait | ||
|
||
main args: | ||
sans10 := Font.get "sans10" | ||
|
||
if args.size != 1: | ||
print "Usage: script.toit png-basename" | ||
exit 1 | ||
driver := TransformedDriver 240 160 args[0] --outline=BLACK | ||
display := PixelDisplay.two-color driver | ||
display.background = WHITE | ||
|
||
text := Label --x=10 --y=55 --text="Hello, World!" --font=sans10 --color=BLACK | ||
display.add text | ||
|
||
display.draw | ||
|
||
driver.write-png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.