All Downloads are FREE. Search and download functionalities are using the official Maven repository.

examples.Match3.src.main.gosu.match3.ImageStoneRenderer.gs Maven / Gradle / Ivy

There is a newer version: 1.18.1
Show newest version
package match3

uses java.awt.Graphics
uses javax.swing.Icon
uses javax.swing.ImageIcon
uses java.awt.Graphics2D

/**
 */
class ImageStoneRenderer implements IStoneRenderer {
  var _icon : ImageIcon
  
  construct( strIconRes: String ) {
    _icon = new ImageIcon( (typeof this).TypeLoader.getResource( strIconRes ) )
  }
  override function render( stone: StoneComponent, g: Graphics ) {
    var x = ((stone.Width-4) - _icon.IconWidth)/2
    var y = ((stone.Height-4) - _icon.IconHeight)/2
    if( x < 0 ) {
      var g2d = g as Graphics2D
      g2d.scale( (stone.Width-4.0)/_icon.IconWidth as double, (stone.Height-4.0)/_icon.IconHeight as double )
      x = 0
      y = 0
    }
    _icon.paintIcon( stone, g, x, y )
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy