Create a figure instance.

    :params width: figure width
    :params height: figure height
176439
def create_figure(width=20, height=10):
    
    figure = plt.figure(figsize=(width, height))
    axis = figure.add_subplot(1, 1, 1)
    return figure, axis
925429
def _scale(self, resource):
        
        original_width, original_height = resource.size

        target_width = int(round(original_width * self.value))
        target_height = int(round(original_height * self.value))

        resource_format = resource.format
        resource = resource.resize((target_width, target_height), Image.ANTIALIAS)
        resource.format = resource_format

        return resource
1151764
def _generate_art(self, image, width, height):
        
        # Characters aren't square, so scale the output by the aspect ratio of a charater
        height = int(height * self._char_width / float(self._char_height))
        image = image.resize((width, height), Image.ANTIALIAS).convert("RGB")

        for (r, g, b) in image.getdata():
            greyscale = int(0.299 * r + 0.587 * g + 0.114 * b)
            ch = self._chars[int(greyscale / 255. * (len(self._chars) - 1) + 0.5)]
            yield (ch, rgb2short(r, g, b))
1136581
def make_fig(self):
        
        self.fig = plt.figure(figsize=(8, 4))
        self._all_figures.append(self.fig)
399731
def set_geometry(im, width_height):
    
    width, height = width_height
    if not width and not height:
        return im

    im_width, im_height = im.size

    # Geometry match the current size?
    if (width is None) or (im_width == width):
        if (height is None) or (im_height == height):
            return im

    ratio = float(im_width) / im_height

    if width and height:
        new_width = width
        new_height = int(ceil(width / ratio))
        if new_height < height:
            new_height = height
            new_width = int(ceil(height * ratio))
    elif height:
        new_width = int(ceil(height * ratio))
        new_height = height
    else:
        new_width = width
        new_height = int(ceil(width / ratio))

    im.resize(new_width, new_height)
    box = get_box(new_width, new_height, width, height)
    im.crop(*box, reset_coords=True)

    return im
1188294
def on_resize(self, width, height):
        
        width, height = self._update_perspective(width, height)
        self.scene.camera.resolution = (width, height)
        self.view['ball'].resize(self.scene.camera.resolution)
        self.scene.camera.transform = self.view['ball'].pose
1128695
def set_size(self, size):
        
        if not isinstance(size, baseinteger):
            raise TypeError("size can only be an instance of type baseinteger")
        self._call("setSize",
                     in_p=[size])
215510
def _init_axis(self, fig, axis):
        
        if not fig and self._create_fig:
            fig = plt.figure()
            l, b, r, t = self.fig_bounds
            inches = self.fig_inches
            fig.subplots_adjust(left=l, bottom=b, right=r, top=t)
            fig.patch.set_alpha(self.fig_alpha)
            if isinstance(inches, (tuple, list)):
                inches = list(inches)
                if inches[0] is None:
                    inches[0] = inches[1]
                elif inches[1] is None:
                    inches[1] = inches[0]
                fig.set_size_inches(list(inches))
            else:
                fig.set_size_inches([inches, inches])
            axis = fig.add_subplot(111, projection=self.projection)
            axis.set_aspect('auto')
        return fig, axis
721408
def resize_to_fill(width, height, img, gravity='Center')
			cols, rows = img[:dimensions]
			img.combine_options do |cmd|
				if width != cols || height != rows
					scale_x = width/cols.to_f
					scale_y = height/rows.to_f
					if scale_x >= scale_y
						cols = (scale_x * (cols + 0.5)).round
						rows = (scale_x * (rows + 0.5)).round
						cmd.resize "#{cols}"
					else
						cols = (scale_y * (cols + 0.5)).round
						rows = (scale_y * (rows + 0.5)).round
						cmd.resize "x#{rows}"
					end
				end

				cmd.gravity gravity
				cmd.background 'rgba(255,255,255,0.0)'
				cmd.extent "#{width}x#{height}" if cols != width || rows != height
			end
		end
369071
def resize(self, width, height):
        
        # this shouldn't be needed
        self.configure_window(width, height)

        self.pgcanvas.resize(width, height)

        # hack to force a browser reload
        app = self.pgcanvas.get_app()
        app.do_operation('reload_page', id=self.pgcanvas.id)
627944
def scale(self, dx=1.0, dy=1.0):
        '''
        

        '''
        self.width *= dx
        self.height *= dy
407154
def new_pic_inline(self, image_descriptor, width, height):
        
        rId, image = self.get_or_add_image(image_descriptor)
        cx, cy = image.scaled_dimensions(width, height)
        shape_id, filename = self.next_id, image.filename
        return CT_Inline.new_pic_inline(shape_id, rId, filename, cx, cy)
44278
def figure_buffer(figs):
    ''''''
    assert len(figs) > 0, 'No figure buffers given. Forgot to return from draw call?'
    buffers = []
    w, h = figs[0].canvas.get_width_height()
    for f in figs:
        wf, hf = f.canvas.get_width_height()
        assert wf == w and hf == h, 'All canvas objects need to have same size'
        buffers.append(np.fromstring(f.canvas.tostring_rgb(), dtype=np.uint8).reshape(h, w, 3))

    return np.stack(buffers)
273300
def resize_canvas(self, height=400, width=400):
        
        self._canvas.configure(width=width, height=height)
311189
def resize(self, width, height):
        
        self.width = width
        self.height = height
        self.buffer_width, self.buffer_height = self.width, self.height
        self.set_default_viewport()

        super().resize(self.buffer_width, self.buffer_height)
47013
def scale_image(self):
        """"""
        new_width = int(self.figcanvas.fwidth *
                        self._scalestep ** self._scalefactor)
        new_height = int(self.figcanvas.fheight *
                         self._scalestep ** self._scalefactor)
        self.figcanvas.setFixedSize(new_width, new_height)
496362
def resize(self, size:Union[int,TensorImageSize]) -> 'ImagePoints':
        ""
        if isinstance(size, int): size=(1, size, size)
        self._flow.size = size[1:]
        return self