This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com

c4d.bitmaps.GeClipMap.GeClipMap - a helper class for BaseBitmaps

This class stores and manipulates a bitmap, providing more advanced drawing tools than BaseBitmap. Just like for bitmaps x = y = 0 is the top left corner. Be sure to call GeClipMap.Init(), GeClipMap.InitFrom() or GeClipMap.InitWith() before you attempt to use a newly allocated clip map.

Note

Though clip maps support other bit depths than 32, the functionality is severly limited. It is recommended that the clip map class is only used for 32 bit bitmaps. (Please note that the default bit depth for BaseBitmap is 24. You need to manually set it to 32 if you use Init>() to initialize the clip map.)

class c4d.bitmaps.GeClipMap

Methods

GeClipMap.__init__()

Creates a new instance of GeClipMap.

Return type:GeClipMap
Returns:The new clipmap.
GeClipMap.Init(w, h[, bits=32])

Initializes the clip map bitmap to the given dimensions and depth. Any previous data is lost.

Parameters:
  • w (int) – Width
  • h (int) – height
  • bits (int) – 32
Return type:

bool

Returns:

True if the initialization was successfull.

GeClipMap.InitWith(bm)

Loads the clip map bitmap from bm. Any previous data is lost.

Parameter:bm (BaseBitmap) – The bitmap to initalize the clip map with.
Return type:bool
Returns:True if the clip map was initialized, otherwise False.
GeClipMap.InitFrom(bm, alpha_channel)

Loads the clip map bitmap from bm. Any previous data is lost.

Parameters:
  • bm (BaseBitmap) – The bitmap to initalize the clip map with.
  • alpha_channel (BaseBitmap) – The alpha channel to use in bm.
Return type:

bool

Returns:

True if the clip map was initialized, otherwise False.

GeClipMap.Destroy()
Resets the clip map to its initial state and frees allocated memory. Requires a new call to init* before the clip map can be used again.
GeClipMap.get_bitmap()

Returns a reference to the internal bitmap.

Return type:BaseBitmap
Returns:The bitmap.
GeClipMap.BeginDraw()
Must be called before any drawing commands. After you called a sequence of drawing commands you should call GeClipMap.end_draw.
GeClipMap.EndDraw()
Must be called before any drawing commands. After you called a sequence of drawing commands you should call GeClipMap.end_draw.
GeClipMap.GetDim()

Retrieves the pixel dimensions of the clip map:

x, y = clmap.GetDim()
GeClipMap.GetBw()

Retrieves the pixel width of the clip map.

Return type:int
Returns:The width.
GeClipMap.GetBh()

Retrieves the pixel height of the clip map.

Return type:int
Returns:The height.
GeClipMap.GetBitmap()

Returns the internal bitmap.

Note

The clip map alpha channel won’t be encoded in this bitmap. This is a limitation.

Return type:BaseBitmap
Returns:The internal bitmap.
GeClipMap.SetColor(r, g, b, alpha)

Checks if the draw operation mode is initialized.

Note

Call begin_draw before

Parameters:
  • r (int) – Red. (Between 0 and 255.).
  • g (int) – Green. (Between 0 and 255.)
  • b (int) – Blue. (Between 0 and 255.)
  • alpha (int) – Alpha value. (Between 0 and 255.)
GeClipMap.SetOffset(off_x, off_y)

Offsets all the following draw commands by this amount.

Note

The clip region isn’t offset.

Parameters:
  • off_x (int) – X distance in pixels.
  • off_y (int) – Y distance in pixels.
GeClipMap.SetDrawMode(mode, par)

Sets the draw mode for the following drawing operations.

Note

Call draw_init before

Parameters:
  • mode (int) –

    Mode.

  • par (int) – Parameter (Depends on mode)
GeClipMap.SetPixel(x, y)

Sets the pixel at (x,y) to the draw color.

Parameters:
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
GeClipMap.Line(x1, y1, x2, y2)

Draws a line from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – First X coordinate.
  • y1 (int) – First Y coordinate.
  • x2 (int) – Second X coordinate.
  • y2 (int) – Second Y coordinate.
GeClipMap.Rect(x1, y1, x2, y2)

Draws the outline of a rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
GeClipMap.FillRect(x1, y1, x2, y2)

Fills a rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
GeClipMap.Arc(x1, y1, x2, y2, seg)

Fills a rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
  • seg

    The arc is drawn in the direction given by:

    0 (x1,y1) -> (x2,y1) -> (x2,y2)
    1 (x2,y1) -> (x2,y2) -> (x1,y2)
    2 (x2,y2) -> (x1,y2) -> (x1,y1)
    3 (x1,y2) -> (x1,y1) -> (x2,y1)
GeClipMap.FillArc(x1, y1, x2, y2, seg)

Draws an arc within the rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
  • seg

    The arc is drawn in the direction given by:

    0 (x1,y1) -> (x2,y1) -> (x2,y2)
    1 (x2,y1) -> (x2,y2) -> (x1,y2)
    2 (x2,y2) -> (x1,y2) -> (x1,y1)
    3 (x1,y2) -> (x1,y1) -> (x2,y1)
GeClipMap.Ellipse(x1, y1, x2, y2)

Draws an ellipse within the rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
GeClipMap.FillEllipse(x1, y1, x2, y2)

Fills an ellipse within the rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
GeClipMap.SetPixelRGBA(x, y, r, g, b[, a=255])

Sets the pixel at (x,y) to the specified color.

Parameters:
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
  • r (int) – Red. (Between 0 and 255.)
  • g (int) – Green. (Between 0 and 255.)
  • b (int) – Blue. (Between 0 and 255.)
  • a (int) – Alpha value. (Between 0 and 255.)
GeClipMap.GetPixelRGBA(x, y)

Retrieves the color of the pixel at (x,y):

r, g, b, a = clmap.GetPixelRGBA(5, 5)
Parameters:
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
Return type:

list of int

Returns:

The color.

GeClipMap.TextAt(x, y, txt)

Prints the string txt with the top left corner at (x,y) in the current draw color.

Parameters:
  • x (int) – Top left X coordinate.
  • y (int) – Top left Y coordinate.
  • txt (str) – Text to print.
GeClipMap.TextWidth(txt)

Calculates the width of the string txt in the current font.

Parameter:txt (str) – The string.
Return type:int
Returns:Calculates the maximum height of a string in the current font.
GeClipMap.TextHeight()
Calculates the maximum height of a string in the current font.
GeClipMap.TextAscent()
Calculates the ascent in the current font. This is the distance from the baseline to the ascender line and usually represents the the height of capital letters.
GeClipMap.ClipPoint(x, y)

Checks if a point is inside the clip region.

Parameters:
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
Return type:

bool

Returns:

True if the point is inside the region, otherwise False.

GeClipMap.ClipArea(x1, y1, x2, y2)

Checks if a rectangle is inside the clip region.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
Return type:

int

Returns:

The result:

GE_CLIP_OUT

Completely outside.

GE_CLIP_ALLIN

Completely inside.

GE_CLIP_PARTIN

Partially inside.

Table Of Contents

This Page