1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2011-2013 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Defines abstract display classes
22 # Any class with a size
24 fun width
: Int is abstract
25 fun height
: Int is abstract
28 # General image class, will be specialized for each classes
32 fun destroy
is abstract
34 # Scale this image when blit
35 var scale
: Float is abstract, writable
37 # Use blending on this image?
38 var blended
: Bool is abstract, writable
40 # Get another image from this one
41 fun subimage
( x
, y
, w
, h
: Int ): Image is abstract
44 # General class for everything drawable to
45 # Is used by drawable images and display
49 # Call to prepare for drawing
52 # Call when drawing is finished
53 fun finish
is abstract
55 # Set viewport for drawing
56 fun set_viewport
( x
, y
, w
, h
: Int ) is abstract
58 # Draw image on self, for top left position
59 fun blit
(image
: I
, x
, y
: Numeric) is abstract
61 # Draw image on self, for top left position but scaled
62 # the width and height of the target rectangle is specified
63 fun blit_scaled
(image
: Image, x
, y
, w
, h
: Numeric)
69 blit_stretched
(image
, fx
, fy
, fx
, fy2
, fx2
, fy2
, fx2
, fy
)
72 # Draw image, centered at position
73 fun blit_centered
(image
: I
, x
, y
: Numeric) is abstract
75 # Draw image, centered at position but rotated
76 fun blit_rotated
(image
: I
, x
, y
: Numeric, angle
: Float) is abstract
78 # Draw image, centered, rotated and scaled
79 fun blit_rotated_scaled
(image
: I
, x
, y
: Numeric, angle
, scale
: Float) is abstract
81 # Draw image by specifying the positon of each image corners
82 # Corners are in counter-clockwise order stating top left
83 # a is top left, b is bottom left, c is bottom right and d is top right
89 fun blit_stretched
(image
: I
, ax
, ay
, bx
, by
, cx
, cy
, dx
, dy
: Numeric)
92 # Clear entire window with given color
93 fun clear
( r
, g
, b
: Float ) is abstract
96 # General display class, is sized and drawable
102 # General drawable display image
103 interface DrawableImage