Previous Next |
Colors, Fonts, Shapes, and Imagesapp developers control what appears on a canvas screen: images, text, and simple shapes. They also control attributes such as the colors used, the fonts, whether lines are drawn with solid or dotted strokes, and so on. ImagesThe guidelines for images drawn onto a canvas are the same as those for image items on forms: Images should be in PNG (portable network graphics) format, and app developers should consider saving them with limited colors to conserve resources. (See "Images" on page 92 for detailed information.) Screen AttributesFor high-level screens, the MIDP implementation sets the colors, the stroke style used for drawing borders, and the font. (app developers can request a font for some high-level entities, such as elements in lists, but there is no guarantee that the request will be honored.) The MIDP implementation makes its use of colors, fonts, and border styles available to the app developer. app Developers
Coordinate SystemDrawing on a canvas involves providing values such as the coordinates at which the object should be drawn, sometimes a height or a width, and so on. This requires an understanding of the coordinate system. The coordinate system has its origin at the upper-left corner. The X coordinates increase left to right, and the Y coordinates increase top to bottom, as shown in Screenshot. Screenshot Coordinate SystemThe coordinates specify the points between pixels. The pixel at (1,1), then, would be drawn below and to the right of coordinate (1,1). It is the pixel bounded by the coordinates (1,1), (1,2), (2,1), and (2,2). Screenshot shows that pixel. Screenshot A Pixel in the Coordinate SystemDrawing and Filling OperationsDrawing a line in the coordinate system touches pixels at both ends. For example, drawing a line from the points (0,3) to (0,5) is three pixels long. Drawing a line from the points (1,1) to (1,1) would result in drawing the pixel shown in Screenshot. Because of the coordinate system and the way that the drawing of lines is specified, filled and drawn (unfilled) shapes have different sizes. An unfilled shape is one pixel larger in width and height than a filled one. MIDP Implementors
app Developers and MIDP Implementors
Anchor PointsDrawing a string or an image requires not only a coordinate but also an anchor point. An anchor point is a combination of a horizontal value (LEFT, RIGHT, or HCENTER) and a vertical value (TOP, BOTTOM, or VCENTER) that indicates which part of the string or image should be placed at the coordinate. Screenshot shows the various anchor points. Screenshot Anchor Points and Their Effectsapp Developers and MIDP Implementors
![]() |
Previous Next |