| [ directory ] |
|
10.4 Colors, Fonts, Shapes, and ImagesApplication 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. 10.4.1 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 application developers should consider saving them with limited colors to conserve resources. (See "Images" on page 92 for detailed information.) 10.4.2 Screen AttributesFor high-level screens, the MIDP implementation sets the colors, the stroke style used for drawing borders, and the font. (Application 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 application developer. Application Developers
10.4.3 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 Figure 10.6. Figure 10.6. Coordinate System
The 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). Figure 10.7 shows that pixel. Figure 10.7. A Pixel in the Coordinate System
10.4.4 Drawing 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 Figure 10.7. 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
Application Developers and MIDP Implementors
10.4.5 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. Figure 10.10 shows the various anchor points. Figure 10.11. Anchor Points and Their Effects
Application Developers and MIDP Implementors
|
| [ directory ] |
|