🧪 Version 0.3.1 is our alpha release candidate. Please send us bug reports and suggestions!

Sketchingpy

Creative coding and interactive science everywhere for everyone: web, desktop, mobile, Jupyter, and more. Open source!

Reference for set_text_align

Indicate the alignment of text to be drawn. This is part of the reference section.

Purpose

Indicate how the text should be aligned horizontally and vertically.
Value Type Meaning
'left' Horizontal Use the x coordinate as the left-most point of the text.
'center' Horizontal Use the x coordinate as location on which to center the text horizontally.
'right' Horizontal Use the x coordinate as right-most point of the text.
'top' Vertical Use the y coordinate as top-most point of the text.
'center' Vertical Use the y coordinate as the location on which to center the text vertically.
'baseline' Vertical Use the y coordinate where the bottom of the text should be placed ignoring decenders.
'bottom' Vertical Use the y coordinate where the bottom of the text should be placed including decenders.
Other options may be added in the future.

Snippet

Draw "Hello World" in 12 point IBM Plex Mono at x coordinate 50 and y coordinate 100 using left horizontal alignment and baseline vertical alignment.
sketch.set_text_font('./IBMPlexMono-Regular.ttf', 12)
sketch.set_text_align('left', 'baseline')
sketch.draw_text(50, 100, 'Hello World')

Parameters

  • horizontal: Argument for horizontal alignment.
  • vertical: Optional additional argument for vertical alignment. If not provided, will default to baseline.

Examples

Availability

Available for all platforms. Additional right to left language support coming soon.

See also