Difference between revisions of "Sprite"

From Sega Retro

(test)
 
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude>My gift to Hivebrain</noinclude><div style="display:none;">
+
<includeonly>{{cropimage
{{#vardefine:nativeSpriteWidth|{{#mediawidth:{{{1}}}}}}}
+
|image={{{1|}}}
{{#vardefine:nativeSpriteHeight|{{#mediaheight:{{{1}}}}}}}
+
|width={{#if: {{{crop_width|}}} | {{{crop_width}}} | }}
 +
|height={{#if: {{{crop_height|}}} | {{{crop_height}}} | }}
 +
|x={{#if: {{{crop_x|}}} | {{{crop_x}}} | }}
 +
|y={{#if: {{{crop_y|}}} | {{{crop_y}}} | }}
 +
|scale={{#if: {{{2|}}} | {{{2}}} | 1 }}
 +
|sprite=yes
 +
}}</includeonly><noinclude>
 +
Display a sprite with optional scaling.
  
{{#vardefine:newSpriteWidth|{{#expr: {{#var:nativeSpriteWidth}} * {{{2}}} }}
+
==Usage==
{{#vardefine:newSpriteHeight|{{#expr: {{#var:nativeSpriteHeight}} * {{{2}}} }}</div>
+
<tt><nowiki>{{</nowiki>sprite|'''{{green|image name.png}}'''|'''{{red|f}}'''}}</tt>
<span style="image-rendering: -moz-crisp-edges; -ms-interpolation-mode: nearest-neighbor;">[[File:{{{1}}}|{{#var:newSpriteWidth}}x{{#var:newSpriteHeight}}]]</span>
+
 
 +
* <tt>{{red|'''f'''}}</tt> = scaling factor (i.e. 2 is double size).
 +
 
 +
===Cropping sprites===
 +
If using a spritesheet, add the following parameters to crop a single sprite:
 +
 
 +
<pre>
 +
{{sprite|image name.png|f
 +
| crop_width=
 +
| crop_height=
 +
| crop_x=
 +
| crop_y=
 +
}}
 +
</pre>
 +
 
 +
[[Category:Templates]]</noinclude>

Latest revision as of 18:08, 1 January 2022

Display a sprite with optional scaling.

Usage

{{sprite|image name.png|f}}

  • f = scaling factor (i.e. 2 is double size).

Cropping sprites

If using a spritesheet, add the following parameters to crop a single sprite:

{{sprite|image name.png|f
| crop_width=
| crop_height=
| crop_x=
| crop_y=
}}