Return new frame size (width and height).
 This size is keeping original aspect ratio.

 @return  [Array]  New width and height size. [width, height]
498339
def calculate_new_size(width, height)
      ratio  = width.to_f / height.to_f
      target = Gnawrnip.max_frame_size

      return [width, height] if target > [width, height].max

      if ratio < 1
        new_width  = target * ratio
        new_height = target
      else
        new_width  = target
        new_height = target / ratio
      end

      [new_width, new_height]
    end
131263
def get_framebuffer_size(window):
    
    width_value = ctypes.c_int(0)
    width = ctypes.pointer(width_value)
    height_value = ctypes.c_int(0)
    height = ctypes.pointer(height_value)
    _glfw.glfwGetFramebufferSize(window, width, height)
    return width_value.value, height_value.value
761762
def new
      @page = ::Page.new

      respond_to do |format|
        format.html # new.html.erb
        format.xml  { render :xml => @page }
      end
    end
683840
synchronized Dimension getPreferredSize() {
        return new Dimension(getFontWidth() * virtualTerminal.getTerminalSize().getColumns(),
                getFontHeight() * virtualTerminal.getTerminalSize().getRows());
    }
1025520
def mutate_keyframes_into_deltaframes! range = nil
      range = 0..self.size if range.nil?
      self.each_with_index do |frame, i|
        if range.include? i
          frame.flag = 0 if frame.is_keyframe?
        end
      end
      self
    end
1368218
def resize(self, size):
        
        super(XLoaderWidget, self).resize(size)
        
        # show small loader
        if size.width() < self._loaderFrame.width() or \
           size.height() < self._loaderFrame.height():
            self._loaderFrame.hide()
            self._smallMovieLabel.show()
        
        # show regular loader
        else:
            self._loaderFrame.show()
            self._smallMovieLabel.hide()
1137658
def set_frame
      frames = @animations[@playing_animation]
      case frames
      when Range
        reset_clipping_rect
        @clip_x = @current_frame * @clip_width
      when Array
        f = frames[@current_frame]
        @clip_x      = f[:x]      || @defaults[:clip_x]
        @clip_y      = f[:y]      || @defaults[:clip_y]
        @clip_width  = f[:width]  || @defaults[:clip_width]
        @clip_height = f[:height] || @defaults[:clip_height]
        @frame_time  = f[:time]   || @defaults[:frame_time]
      end
    end
1292722
function (width, height) {
            this._updateFrameWidth(width);
            this._frame.resize(this._frameWidth, height);
            this.innerWidth = this._frame.innerWidth;
            this.innerHeight = this._frame.innerHeight;
        }
26362
function( width, height ){

            var layer;
            proto.resize.call( this, width, height );

            for ( var id in this._layers ){

                layer = this._layers[ id ];
                if ( layer.options.autoResize ){
                    layer.el.width = this.width;
                    layer.el.height = this.height;
                }
            }

            return this;
        }
256832
function resize($new_width, $new_height)
    {
        $width = $this->width;
        $height = $this->height;

        if( $width > $height )
        {
            $new_height = ($new_width / $width) * $height;
        }
        elseif($height > $width)
        {
            $new_width = ($new_height / $height) * $width;
        }

        $image = imagecreatetruecolor( $new_width, $new_height );
        imagecopyresampled($image, $this->image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

        $this->width = imagesx($image);
        $this->height = imagesy($image);
        $this->image = $image;
    }
902833
def frame
      return @frame if @frame

      chars = []
      # 4 corners
      chars << Char.new(0x23, @x_offset - 1, @y_offset - 1)               # TopLeft
      chars << Char.new(0x23, @x_offset + @width, @y_offset - 1)          # TopRight
      chars << Char.new(0x23, @x_offset - 1, @y_offset + @height)         # BottomLeft
      chars << Char.new(0x23, @x_offset + @width, @y_offset  + @height)   # BottomRight

      # horiz
      @width.times { |x| chars << Char.new(0x2d, x + @x_offset, @y_offset - 1) }
      @width.times { |x| chars << Char.new(0x2d, x + @x_offset, @y_offset + @height) }

      # vertical
      @height.times { |y| chars << Char.new(0x7c, @x_offset - 1, y + @y_offset) }
      @height.times { |y| chars << Char.new(0x7c, @x_offset + @width, y + @y_offset) }
      @frame = ""
      @frame << chars.join
    end
1308311
public function initDimensions()
    {
        $this->log("Init dimension (before) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.");

        // width as %
        if ($this->newWidth[strlen($this->newWidth)-1] == '%') {
            $this->newWidth = $this->width * substr($this->newWidth, 0, -1) / 100;
            $this->log("Setting new width based on % to {$this->newWidth}");
        }

        // height as %
        if ($this->newHeight[strlen($this->newHeight)-1] == '%') {
            $this->newHeight = $this->height * substr($this->newHeight, 0, -1) / 100;
            $this->log("Setting new height based on % to {$this->newHeight}");
        }

        is_null($this->aspectRatio) or is_numeric($this->aspectRatio) or $this->raiseError('Aspect ratio out of range');

        // width & height from aspect ratio
        if ($this->aspectRatio && is_null($this->newWidth) && is_null($this->newHeight)) {
            if ($this->aspectRatio >= 1) {
                $this->newWidth   = $this->width;
                $this->newHeight  = $this->width / $this->aspectRatio;
                $this->log("Setting new width & height based on width & aspect ratio (>=1) to (w x h) {$this->newWidth} x {$this->newHeight}");

            } else {
                $this->newHeight  = $this->height;
                $this->newWidth   = $this->height * $this->aspectRatio;
                $this->log("Setting new width & height based on width & aspect ratio (<1) to (w x h) {$this->newWidth} x {$this->newHeight}");
            }

        } elseif ($this->aspectRatio && is_null($this->newWidth)) {
            $this->newWidth   = $this->newHeight * $this->aspectRatio;
            $this->log("Setting new width based on aspect ratio to {$this->newWidth}");

        } elseif ($this->aspectRatio && is_null($this->newHeight)) {
            $this->newHeight  = $this->newWidth / $this->aspectRatio;
            $this->log("Setting new height based on aspect ratio to {$this->newHeight}");
        }

        // Change width & height based on dpr
        if ($this->dpr != 1) {
            if (!is_null($this->newWidth)) {
                $this->newWidth  = round($this->newWidth * $this->dpr);
                $this->log("Setting new width based on dpr={$this->dpr} - w={$this->newWidth}");
            }
            if (!is_null($this->newHeight)) {
                $this->newHeight = round($this->newHeight * $this->dpr);
                $this->log("Setting new height based on dpr={$this->dpr} - h={$this->newHeight}");
            }
        }

        // Check values to be within domain
        is_null($this->newWidth)
            or is_numeric($this->newWidth)
            or $this->raiseError('Width not numeric');

        is_null($this->newHeight)
            or is_numeric($this->newHeight)
            or $this->raiseError('Height not numeric');

        $this->log("Init dimension (after) newWidth x newHeight is {$this->newWidth} x {$this->newHeight}.");

        return $this;
    }
192719
def get_size(self):
        
        rec = self.get_rectangle()
        return (int(rec[2]-rec[0]), int(rec[3]-rec[1]))
965801
def view(x, y, width, height)
      view = View.new(self, x, y, width, height)

      return view unless block_given?

      begin
        yield(view)
      ensure
        view.sync
      end
      nil
    end
637580
def scale_image(image, new_width):
    
    (original_width, original_height) = image.size
    aspect_ratio = original_height/float(original_width)
    new_height = int(aspect_ratio * new_width)

    # This scales it wider than tall, since characters are biased
    new_image = image.resize((new_width*2, new_height))
    return new_image
908990
def size(self, size):
        
        clone = self._clone()
        clone._size = size
        return clone
948972
public function withSize($newWidth, $newHeight)
    {
        $newDimension = clone $this;

        if ($newWidth == 0 && $newHeight > 0) {
            $newDimension->withHeight($newHeight);
            $newWidth = $newDimension->getWidth();
        } else {
            if ($newWidth > 0 && $newHeight == 0) {
                $newDimension->withWidth($newWidth);
                $newHeight = $newDimension->getHeight();
            }
        }

        $targetDimension = clone $this;

        if ($this->directive === 'UP') {
            if ($newWidth > $this->width) {
                $targetDimension->width = $newWidth;
                $targetDimension->height = $newHeight;

                return $targetDimension;
            } elseif ($newWidth < $this->width) {
                return $targetDimension;
            }
        } elseif ($this->directive === 'DOWN') {
            if ($newWidth > $this->width) {
                return $targetDimension;
            } elseif ($newWidth < $this->width) {
                $targetDimension->width = $newWidth;
                $targetDimension->height = $newHeight;

                return $targetDimension;
            }
        }

        if ($this->maintainAspectRatio) {
            $targetDimension->width = $newWidth > $this->width ? $this->width : $newWidth;
            $targetDimension->height = $newHeight > $this->height ? $this->height : $newHeight;
        } else {
            $targetDimension->width = (int)$newWidth;
            $targetDimension->height = (int)$newHeight;
        }

        return $targetDimension;
    }