Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Image Scaling — Gideros Forum

Image Scaling

CyberienceCyberience Member
edited January 2013 in General questions
Am I missing something, or is it, I must have am image fixed at each resolution ?I need. what I mean is, not scaling functions, so if I have a 32x32, I cant stretch or shrink it as I need?
In HTML5 I have an image place function that has parameter to indicate the width and hieght of the slected image, so once represents the crop, the other represents the placement.

I am using local hazard = Bitmap.new(Texture.new(p_image)) to select the image
and the usual properties for position and angle etc,
plus I cant seem to find a list of these built in properties so I can look up the options.
Any ideas or guidance extremely welcome.

Likes: WauloK

REAL programmers type copy con filename.exe
---------------------------------------
Tagged:
+1 -1 (+1 / -0 )Share on Facebook

Comments

  • SinisterSoftSinisterSoft Maintainer
    Accepted Answer
    :setScale(0 - 1.0)

    Likes: Cyberience

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • @Cyberience there is a reference manual with all the methods from all objects
    Here online: http://www.giderosmobile.com/documentation/reference_manual.html

    Or locally on your computer, open Gideros Studio, click About -> API Documentation

    There are properties used in API, usually only methods.

    Likes: Cyberience

    +1 -1 (+1 / -0 )Share on Facebook
  • CyberienceCyberience Member
    edited March 2013
    What I am trying to do is take Images of variable sizes, and thumb nail them.
    A game feature, when I click on a game object, to show its active I expand it breifly and shrink it back, this is a good Visual trick to make the experience nicer, though I am still struggling with the Matrix thing and how to expan and shrink images within the Gideros tool set.
    I think Matrix is where it is, and I can use scaling for the minor effects, but the problem I am having is the variable images, whether it is 300x300 or 20x20 I want to place it into a 50x50 box.

    Any suggestions?
    REAL programmers type copy con filename.exe
    ---------------------------------------
  • ar2rsawseenar2rsawseen Maintainer
    edited March 2013 Accepted Answer
    @Cyberience a bit of the math will do the magic trick ;)
    function Sprite:setWidth(newWidth)
    	-- Set a sprite's width using the scale property
    	local x,y,width,height=self:getBounds(self)
    	local newScale=newWidth/width
    	self:setScaleX(newScale)
    end
     
    function Sprite:setHeight(newHeight)
    	-- Set a sprite's height using the scale property
    	local x,y,width,height=self:getBounds(self)
    	local newScale=newHeight/height
    	self:setScaleY(newScale)
    end
     
    --then use it as
    someimage:setWidth(50)

    Likes: Cyberience

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.