From c193e6e50dcff54461c220ca3ca4505b7804d9a2 Mon Sep 17 00:00:00 2001 From: Erik Corry Date: Thu, 14 Dec 2023 14:30:56 +0100 Subject: [PATCH] Tweak the docs --- src/element.toit | 2 +- src/four-gray.toit | 6 +++--- src/gray-scale.toit | 8 ++++++-- src/{one-byte.toit => one-byte_.toit} | 0 src/pixel-display.toit | 22 +++++++++++++++++---- src/several-color.toit | 2 +- src/style.toit | 2 +- src/three-color.toit | 6 +++--- src/true-color.toit | 6 +++++- src/{two-bit-texture.toit => two-bit_.toit} | 0 src/two-color.toit | 4 ++-- tests/texture-test-slow.toit | 4 ++-- 12 files changed, 42 insertions(+), 20 deletions(-) rename src/{one-byte.toit => one-byte_.toit} (100%) rename src/{two-bit-texture.toit => two-bit_.toit} (100%) diff --git a/src/element.toit b/src/element.toit index b68d965..55652df 100644 --- a/src/element.toit +++ b/src/element.toit @@ -7,7 +7,7 @@ import bitmap show * import .four-gray as four-gray import .true-color as true-color import .gray-scale as gray-scale -import .one-byte as one-byte +import .one-byte_ as one-byte import .style show * import .pixel-display import font show Font diff --git a/src/four-gray.toit b/src/four-gray.toit index 549b073..6c11bfc 100644 --- a/src/four-gray.toit +++ b/src/four-gray.toit @@ -3,7 +3,7 @@ // found in the LICENSE file. /** -Constants useful for $PixelDisplay.four-gray. +Constants useful for $pixel-display.PixelDisplay.four-gray. For use with e-paper displays with four tones of gray. */ @@ -11,8 +11,8 @@ import bitmap show * import font show Font import .pixel-display -import .two-bit-texture -import .two-bit-texture as two-bit +import .pixel-display as pixel-display +import .two-bit_ as two-bit /// Color value for use with $PixelDisplay.four-gray. WHITE ::= 0 diff --git a/src/gray-scale.toit b/src/gray-scale.toit index e8557ab..5d952cf 100644 --- a/src/gray-scale.toit +++ b/src/gray-scale.toit @@ -3,13 +3,17 @@ // found in the LICENSE file. /** -Constants useful for $PixelDisplay.gray-scale. +Constants useful for $pixel-display.PixelDisplay.gray-scale. +These are displays with 8-bit pixels, where each pixel is a gray-scale value + from 0 (black) to 255 (white). */ import bitmap show * import font show Font + import .pixel-display -import .one-byte +import .pixel-display as pixel-display +import .one-byte_ /// Color value for use with $PixelDisplay.gray-scale. WHITE ::= 255 diff --git a/src/one-byte.toit b/src/one-byte_.toit similarity index 100% rename from src/one-byte.toit rename to src/one-byte_.toit diff --git a/src/pixel-display.toit b/src/pixel-display.toit index e00abb1..4e03e8e 100644 --- a/src/pixel-display.toit +++ b/src/pixel-display.toit @@ -15,12 +15,12 @@ import .bar-code import .element import .two-color as two-color import .three-color as three-color -import .two-bit-texture as two-bit +import .two-bit_ as two-bit import .four-gray as four-gray import .true-color as true-color import .gray-scale as gray-scale import .several-color as several-color -import .one-byte as one-byte +import .one-byte_ as one-byte import .style FLAG-2-COLOR ::= 0b1 @@ -749,9 +749,24 @@ abstract class Canvas: */ abstract create-similar -> Canvas + /** + Sets all pixels in the canvas to the given color. + For true-color canvases, the color has the form 0xRRGGBB. + For gray-scale canvases, the color has the form 0xGG. + For other canvases types, constants are defined in their respective import + files. + */ abstract set-all-pixels color/int -> none + /** + Returns true for true-color and gray-scale canvases that support + 8-bit drawing methods. + */ abstract supports-8-bit -> bool + + /** + Returns true for gray-scale canvases and two-color black/white canvases. + */ abstract gray-scale -> bool /** @@ -924,8 +939,7 @@ abstract class Canvas: descenders or starts with a character like "J" or "/", which in many fonts extend to the left of their origin. */ - abstract text x/int y/int --text/string --color/int --font/Font --orientation/int - abstract text x/int y/int --text/string --color/int --font/Font + abstract text x/int y/int --text/string --color/int --font/Font --orientation/int=0 /** Draws the given bitmap on the canvas. diff --git a/src/several-color.toit b/src/several-color.toit index 66bbec5..67e1365 100644 --- a/src/several-color.toit +++ b/src/several-color.toit @@ -4,7 +4,7 @@ import bitmap show * import font show Font -import .one-byte +import .one-byte_ import .two-color as two-color import .pixel-display diff --git a/src/style.toit b/src/style.toit index 76c0626..2591335 100644 --- a/src/style.toit +++ b/src/style.toit @@ -7,7 +7,7 @@ import bitmap show ORIENTATION-0 ORIENTATION-90 ORIENTATION-180 ORIENTATION-270 import font show Font import .element as element -import .one-byte as one-byte +import .one-byte_ as one-byte import .pixel-display ALIGN-LEFT ::= 0 diff --git a/src/three-color.toit b/src/three-color.toit index d267e25..f1e593b 100644 --- a/src/three-color.toit +++ b/src/three-color.toit @@ -3,15 +3,15 @@ // found in the LICENSE file. /** -Constants useful for $PixelDisplay.three-color. +Constants useful for $pixel-display.PixelDisplay.three-color. For use with e-paper black, white, and red displays. */ import font show Font import .pixel-display -import .two-bit-texture -import .two-bit-texture as two-bit +import .pixel-display as pixel-display +import .two-bit_ as two-bit WHITE ::= 0 BLACK ::= 1 diff --git a/src/true-color.toit b/src/true-color.toit index 429f0bc..567f3a8 100644 --- a/src/true-color.toit +++ b/src/true-color.toit @@ -3,14 +3,18 @@ // found in the LICENSE file. /** -Functions and constants useful for the RGB $PixelDisplay.true-color display. +Functions and constants useful for the RGB + $pixel-display.PixelDisplay.true-color display. +See for example https://pkg.toit.io/search?query=color-tft */ import binary show BIG-ENDIAN import bitmap show * import font show Font + import .gray-scale as gray-scale_ import .pixel-display +import .pixel-display as pixel-display /** Create a 24 bit color from three components in the 0-255 range. diff --git a/src/two-bit-texture.toit b/src/two-bit_.toit similarity index 100% rename from src/two-bit-texture.toit rename to src/two-bit_.toit diff --git a/src/two-color.toit b/src/two-color.toit index dbd87db..67894d1 100644 --- a/src/two-color.toit +++ b/src/two-color.toit @@ -3,7 +3,7 @@ // found in the LICENSE file. /** -Constants useful for black-and-white $PixelDisplay.two-color. +Constants useful for black-and-white $pixel-display.PixelDisplay.two-color. For use with e-paper displays and the SSD1306 128x64 display (driver at https://pkg.toit.io/package/ssd1306&url=github.com%2Ftoitware%2Ftoit-ssd1306&index=latest) */ @@ -12,10 +12,10 @@ import bitmap show * import font show Font import .pixel-display +import .pixel-display as pixel-display WHITE ::= 0 BLACK ::= 1 -TRANSPARENT ::= 3 // The canvas contains a bitmapped ByteArray. // Starts off with/ all pixels white. diff --git a/tests/texture-test-slow.toit b/tests/texture-test-slow.toit index b024e09..30251c0 100644 --- a/tests/texture-test-slow.toit +++ b/tests/texture-test-slow.toit @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Toitware ApS. +// Copyright (C) 2023 Toitware ApS. // Use of this source code is governed by a Zero-Clause BSD license that can // be found in the TESTS_LICENSE file. @@ -10,7 +10,7 @@ import font show * import pixel-display show Transform import pixel-display.four-gray -import pixel-display.two-bit-texture as two-bit +import pixel-display.two-bit_ as two-bit import pixel-display.three-color import pixel-display.true-color import pixel-display.two-color