Peter Ward avatar Peter Ward committed 2baa985

add primitives

Comments (0)

Files changed (2)

docs/fake/shinypress/render.py

+class ScalingMode(object):
+    """
+    Scaling modes for use with the scale() function.
+
+    :var NONE: don't change the content size
+    :var KEEP_ASPECT: make the content as large as possible without changing the
+        aspect ratio
+    :var STRETCH: fill the target area with the content
+    :var ZOOM: fill the target area completely without changing the aspect ratio
+    """
+    NONE = 0
+    KEEP_ASPECT = 1
+    STRETCH = 2
+    ZOOM = 3
+
+def scale(content_size, target_size, scaling_mode):
+    """
+    Determine the size at which the given content should be drawn in order to
+    fit the given target area.
+
+    :param content_size: the size of the content to be rendered
+    :type content_size: a (width, height) tuple
+    :param target_size: the size of the area it should fit in
+    :type target_size: a (width, height) tuple
+    :param scaling_mode: how to resize the content
+    :type scaling_mode: shinypress.render.ScalingMode
+    :rtype: a (width, height) tuple
+    """
+    pass
+
+def render_image(
+    ctx, image, size,
+    scaling_mode=ScalingMode.KEEP_ASPECT,
+):
+    """
+    Render an image onto the given Cairo context using the given scaling mode.
+
+    :param ctx: a Cairo context
+    :param image: the image to be rendered
+    :param size: the dimensions of the image box
+    :type size: a (width, height) tuple
+    :param scaling_mode: how to resize the image to fit the image box
+    :type scaling_mode: shinypress.render.ScalingMode
+    """
+    pass
+
+def render_text(ctx, text, size, **todo_fill_in_these_kwargs):
+    """
+    Render some text onto the given Cairo context.
+
+    :param ctx: a Cairo context
+    :param text: the text to be rendered
+    :type text: unicode
+    :param size: the dimensions of the text box
+    :type size: a (width, height) tuple
+    """
+    pass
             theme.render(ctx, template, blocks)
             surf.show_page()
 
+Primitives
+~~~~~~~~~~
+
+There are some simple functions provided for rendering text and images:
+
+.. automodule:: shinypress.render
+    :members:
+
 Handlers
 ~~~~~~~~
 Handlers must be an object which specifies a ``layout`` method which takes a
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.