|
ActiveTcl User Guide
|
||
Tk_CanvasPsY, Tk_CanvasPsBitmap, Tk_CanvasPsColor, Tk_CanvasPsFont, Tk_CanvasPsPath, Tk_CanvasPsStipple - utility procedures for generating Postscript for canvases
#include <tk.h>
double
Tk_CanvasPsY(canvas, canvasY)
int
Tk_CanvasPsBitmap(interp, canvas, bitmap, x, y, width,
height)
int
Tk_CanvasPsColor(interp, canvas, colorPtr)
int
Tk_CanvasPsFont(interp, canvas, tkFont)
Tk_CanvasPsPath(interp, canvas, coordPtr,
numPoints)
int
Tk_CanvasPsStipple(interp, canvas, bitmap)
These procedures are called by canvas type managers to carry out common functions related to generating Postscript. Most of the procedures take a canvas argument, which refers to a canvas widget for which Postscript is being generated.
Tk_CanvasPsY takes as argument a y-coordinate in the space of a canvas and returns the value that should be used for that point in the Postscript currently being generated for canvas. Y coordinates require transformation because Postscript uses an origin at the lower-left corner whereas X uses an origin at the upper-left corner. Canvas x coordinates can be used directly in Postscript without transformation.
Tk_CanvasPsBitmap generates Postscript to describe a region of a bitmap. The Postscript is generated in proper image data format for Postscript, i.e., as data between angle brackets, one bit per pixel. The Postscript is appended to interp->result and TCL_OK is returned unless an error occurs, in which case TCL_ERROR is returned and interp->result is overwritten with an error message.
Tk_CanvasPsColor generates Postscript to set the current color to correspond to its colorPtr argument, taking into account any color map specified in the postscript command. It appends the Postscript to interp->result and returns TCL_OK unless an error occurs, in which case TCL_ERROR is returned and interp->result is overwritten with an error message.
Tk_CanvasPsFont generates Postscript that sets the current font to match tkFont as closely as possible. Tk_CanvasPsFont takes into account any font map specified in the postscript command, and it does the best it can at mapping X fonts to Postscript fonts. It appends the Postscript to interp->result and returns TCL_OK unless an error occurs, in which case TCL_ERROR is returned and interp->result is overwritten with an error message.
Tk_CanvasPsPath generates Postscript to set the current path to the set of points given by coordPtr and numPoints. It appends the resulting Postscript to interp->result.
Tk_CanvasPsStipple generates Postscript that will fill the current path in stippled fashion. It uses bitmap as the stipple pattern and the current Postscript color; ones in the stipple bitmap are drawn in the current color, and zeroes are not drawn at all. The Postscript is appended to interp->result and TCL_OK is returned, unless an error occurs, in which case TCL_ERROR is returned and interp->result is overwritten with an error message.
bitmap, canvas, color, font, path, Postscript, stipple
Copyright © 1994-1996 Sun Microsystems, Inc. Copyright © 1995-1997 Roger E. Critchlow Jr.


Basketball: 'Amazing' Harden erupts for 47 points as Rockets down Clippers
LOS ANGELES: James Harden was labelled "amazing" by Houston coach Mike D'Antoni after erupting in a fourth-quarter scoring spree to lead the Rockets to a 102-93 victory over the Los Angeles Clippers on Wednesday (Nov 13).
Harden led the scoring with 47 points, including seven three-pointers, while the former NBA MVP also added six rebounds and seven assists.
The Houston talisman plundered 17 points late in the fourth quarter to help transform an 84-80 deficit with 5min 52sec remaining into victory.
"It's not like we haven't seen it before, and we'll see it again," Rockets head coach D'Antoni said.
"He's amazing. He's just a master of the game. It's what I expect. He's a special player, no doubt about it."
Harden shouldered the bulk of the Rockets' offensive duties, with Russell Westbrook (17) and Clint Capela (12) the only other Houston players to score double figures.
The Clippers were led by Kawhi Leonard, who had 26 points, 12 rebounds and seven assists.
Lou Williams had 20 off the bench for the Clippers while JaMychal Green added 14 as the Clippers fell to 7-4 with the defeat.
The Clippers also had coach Doc Rivers ejected in a surreal exchange late in the fourth quarter which saw his son - Rockets shooting guard Austin Rivers - urging officials to toss him.
"It was a really good moment," Austin Rivers joked afterwards.
"I enjoyed it a lot.  I really did enjoy that."
LAKERS ROUT WARRIORS
The Rockets improved to 8-3, leaving them hard on the heels of the Los Angeles Lakers, who cruised to a blowout 120-94 win over the injury-decimated Golden State Warriors on Wednesday.
The Warriors, who reached five consecutive NBA Finals from 2015-2019 have endured a nightmare start to the season, with a long-term injury to Stephen Curry depleting a squad already attempting to adjust from the loss of Klay Thompson (knee) and departure of Kevin Durant to the Brooklyn Nets.
The Lakers were in no mood to show the Warriors any mercy at the Staples Center on Wednesday, LeBron James scoring 23 points and Kyle Kuzma 22 in a comfortable win.
The Lakers, who have not have reached the playoffs since 2013, lead the Western Conference with a 9-2 record.
In the Eastern Conference, the Boston Celtics improved to 9-1 to remain on top of the table after a 140-133 defeat of the Washington Wizards.
Kemba Walker had 25 points in an impressive all-round scoring display by the Celtics, who saw seven players reach double digits.
Walker was backed by Jayson Tatum with 23 points and Jaylen Brown with 22. Turkish star Enes Kanter meanwhile pulled down nine rebounds as well as contributing 13 points.
But it was a frustrating night for Washington's Bradley Beal, who finished with 44 points, five rebounds and six assists yet somehow ended on the losing side.
In Orlando, Nikola Vucevic scored 25 points as the Magic jolted the Philadelphia 76ers with a 112-97 victory.
The Sixers, playing without the injured Joel Embiid, fell to 7-4 after the loss while Joel Embiid Orlando improved to 4-7.
In Portland, the reigning NBA champion Toronto Raptors eased past the Trail Blazers after another superb display from Pascal Siakam.
Siakam, who had scored 24 points in a win over the Lakers on Sunday, once again led the scoring with 36 points, receiving backing from Fred VanVleet who finished with 30.


Gracenote provides a mechanism for you to use a local database of track fingerprints and metadata for identification. The SDK can use this database to attempt a local ID prior to going online. Doing this provides a significant performance improvement if a local match is found.
To create a local database, you need to download and ingest raw fingerprint and metadata from Gracenote, packaged in an entity called a bundle. Currently, you have to work with Gracenote Global Support & Services (GSS) to create a bundle. In the future, Gracenote will provide a self-service tool to do this. Having a local database requires that a storage provider, such as SQLite be enabled. You can do this with the GnStorageSqlite
class.
Your application can ingest multiple bundles. If the same track exists in multiple ingested bundles it is added to the local database only once with the most recent/up-to-date track information. The ingestion process can be lengthy; your application may want to do this on a background thread to avoid stalling the main application thread.
To implement local lookup, use the following GnLookupLocalStream
methods :
Enable
—Enables the LookupLocalStream
library.
StorageLocation
—Sets the location for your MusicID-Stream fingerprint database . Bundle ingestion creates the database at the location specified. If the path does not exist, ingestion will fail.
StorageRemove
—Removes an item from the local fingerprint database.
StorageClear
—Clears all tracks from the local fingerprint database.
And the following GnLookupLocalStreamIngest
methods:
Write
—Takes byte data and writes specified number of bytes to local storage.
Flush
—Flushes the memory cache to the file storage and commits the changes. This method ensures that everything written is commited to the file system. Note that this is an optional call as internally data is flushed when it exceed the cache size and when the object goes out of scope.
Note that the GnLookupLocalStreamIngest
constructor takes a callback object to handle statuses as the ingest process can take some time. See the API reference documentation for GnLookupLocalStreamIngest
for more information.
To manage bundles, your application would typically need to do the following:
Manually retrieve a Gracenote-provided bundle
Place bundle in an online location that your application can access
Have your application download and ingest the bundle.
Note: Bundles should be retrieved from an online source. Gracenote recommends that when your application is installed or initialized that it download and ingest the latest bundle rather than ship with a bundle as part of the application binaries.
Ingesting bundles code samples:
// Enable storage provider allowing GNSDK to use its persistent stores GnStorageSqlite.enable(); // Enable local MusicID-Stream recognition (GNSDK storage provider must be enabled as pre-requisite) GnLookupLocalStream.enable(); // Ingest MusicID-Stream local bundle, perform in another thread as it can be lengthy Thread ingestThread = new Thread( new LocalBundleIngestRunnable(context) ); ingestThread.start(); /** * Loads a local bundle for MusicID-Stream lookups */ class LocalBundleIngestRunnable implements Runnable { Context context; LocalBundleIngestRunnable(Context context) { this.context = context; } public void run() { try { // Our bundle is delivered as a package asset // to ingest the bundle access it as a stream and write the bytes to // the bundle ingester. // Bundles should not be delivered with the package as this, rather they // should be downloaded from your own online service. InputStream bundleInputStream = null; int ingestBufferSize = 1024; byte[] ingestBuffer = new byte[ingestBufferSize]; int bytesRead = 0; GnLookupLocalStreamIngest ingester = new GnLookupLocalStreamIngest(new BundleIngestEvents()); try { bundleInputStream = context.getAssets().open("1557.b"); do { bytesRead = bundleInputStream.read(ingestBuffer, 0, ingestBufferSize); if ( bytesRead == -1 ) bytesRead = 0; ingester.write( ingestBuffer, bytesRead ); } while( bytesRead != 0 ); } catch (IOException e) { e.printStackTrace(); } ingester.flush(); } catch (GnException e) { Log.e( appString, e.errorCode() + ", " + e.errorDescription() + ", " + e.errorModule() ); } } }
- (NSError *) setupLocalLookup { NSError * error = nil; /* Initialize the local lookup so we can do local lookup queries. */ self.gnLookupLocalStream = [GnLookupLocalStream enable: &error]; if (! error) { NSString * docDir = [GnAppDelegate applicationDocumentsDirectory]; [self.gnLookupLocalStream storageLocation: docDir error: &error]; if (! error) { // Look for the 10,000 track bundle and if not found try the little one. NSString* bundlePath = [[NSBundle mainBundle] pathForResource: @"1557.b" ofType: nil]; if (bundlePath) { [self.gnLookupLocalStream storageClear: &error]; if (! error) { __block GnLookupLocalStreamIngest *lookupLocalStreamIngest = [[GnLookupLocalStreamIngest alloc] initWithGnLookupLocalStreamIngestEventsDelegate:self]; // Load Bundle in a separate thread to keep the UI responsive. This is required for Large Bundles that can take few minutes to be ingested. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ NSError *error = nil; NSInteger bytesRead = 0; double totalBytesRead = 0; uint8_t buffer[1024]; NSInputStream *fileInputStream = [NSInputStream inputStreamWithFileAtPath:bundlePath]; [fileInputStream open]; do { bytesRead = [fileInputStream read:buffer maxLength:1024]; [lookupLocalStreamIngest write:buffer dataSize:sizeof(buffer) error:&error]; if(error) { NSLog(@"Error during lookupLocalStreamIngest write: %@", [error localizedDescription]); } totalBytesRead+=bytesRead; }while (bytesRead>0); [lookupLocalStreamIngest flush:&error]; [fileInputStream close]; }); } } } } return error; }
// Ingest local fingerprint bundle GnLookupLocalStream lookupLocalStream = GnLookupLocalStream.Enable; lookupLocalStream.StorageLocation(Windows.Storage.ApplicationData.Current.LocalFolder.Path); GnLookupLocalStreamIngest lookupLocalStreamIngest = new GnLookupLocalStreamIngest(this); // Bundle assset path including asset name. The code assumes that the bundle // to be ingested was added to the project as a content file. string bundlePath = "1557.b"; Stream bundleFileStream = Application.GetResourceStream(new Uri(bundlePath, UriKind.Relative)).Stream; byte[] buffer = new byte[1024 + 10]; int count = 1024; int read = 0; while (0 != (read = bundleFileStream.Read(buffer, 0, count))) { lookupLocalStreamIngest.Write(buffer, (uint)read); } lookupLocalStreamIngest.Flush();
A storage provider module implements GNSDK local storage. There are currently two available GNSDK storage providers: SQLite and QNX's QDB.
By default, no storage provider is enabled.To use SQLite, your application needs to instantiate a GnStorageSqlite
object and call its enable
method.