# Class cc.DrawingPrimitiveCanvas

Class Summary
Constructor Attributes Constructor Name and Description

Canvas of DrawingPrimitive implement version

## Class Detail

cc.DrawingPrimitiveCanvas()
Canvas of DrawingPrimitive implement version

## Method Detail

• drawCardinalSpline(config, tension, segments)
draw a cardinal spline path
Parameters:
{Array} config
{Number} tension
{Number} segments
• drawCatmullRom(points, segments)
draw a CatmullRom curve
Parameters:
{Array} points
{Number} segments
• drawCircle(center, radius, angle, segments, drawLineToCenter)
draws a circle given the center, radius and number of segments.
Parameters:
{cc.Point} center
center of circle
{Number} angle
{Number} segments
{Boolean} drawLineToCenter Optional
draw a color ball
Parameters:
{CanvasRenderingContext2D} ctx
canvas context
color
• drawCubicBezier(origin, control1, control2, destination, segments)
draws a cubic bezier path
Parameters:
{cc.Point} origin
{cc.Point} control1
{cc.Point} control2
{cc.Point} destination
{Number} segments
• drawImage(image, sourcePoint, sourceSize, destPoint, destSize)
draw an image
Parameters:
{HTMLImageElement|HTMLCanvasElement} image
{cc.Point} sourcePoint
{cc.Size} sourceSize
{cc.Point} destPoint
{cc.Size} destSize
• drawLine(origin, destination)
draws a line given the origin and destination point measured in points
Parameters:
{cc.Point} origin
{cc.Point} destination
• drawPoint(point, size)
draws a point given x and y coordinate measured in points
Parameters:
{cc.Point} point
{Number} size
• drawPoints(points, numberOfPoints, size)
draws an array of points.
Parameters:
{Array} points
point of array
{Number} numberOfPoints
{Number} size
• drawPoly(vertices, numOfVertices, closePolygon, fill)
draws a polygon given a pointer to cc.Point coordiantes and the number of vertices measured in points.
Parameters:
{Array} vertices
a pointer to cc.Point coordiantes
{Number} numOfVertices
the number of vertices measured in points
{Boolean} closePolygon
The polygon can be closed or open
{Boolean} fill Optional
The polygon can be closed or open and optionally filled with current color
Parameters:
{cc.Point} origin
{cc.Point} control
{cc.Point} destination
{Number} segments
• drawRect(origin, destination)
draws a rectangle given the origin and destination point measured in points.
Parameters:
{cc.Point} origin
{cc.Point} destination
• drawSolidPoly(poli, numberOfPoints, color)
draws a solid polygon given a pointer to CGPoint coordiantes, the number of vertices measured in points, and a color.
Parameters:
{Array} poli
{Number} numberOfPoints
color
• drawSolidRect(origin, destination, color)
draws a solid rectangle given the origin and destination point measured in points.
Parameters:
{cc.Point} origin
{cc.Point} destination
color
draw a star
Parameters:
{CanvasRenderingContext2D} ctx
canvas context
color
• fillText(strText, x, y)
fill text
Parameters:
{String} strText
{Number} x
{Number} y
• setDrawColor4B(r, g, b, a)
set the drawing color with 4 unsigned bytes
Parameters:
{Number} r
red value (0 to 255)
{Number} g
green value (0 to 255)
{Number} b
blue value (0 to 255)
{Number} a
Alpha value (0 to 255)
• setDrawColor4F(r, g, b, a)
set the drawing color with 4 floats
Parameters:
{Number} r
red value (0 to 1)
{Number} g
green value (0 to 1)
{Number} b
blue value (0 to 1)
{Number} a
Alpha value (0 to 1)
• setLineWidth(width)
set the line width. Default 1.
Parameters:
{Number} width
• setPointSize(pointSize)
set the point size in points. Default 1.
Parameters:
{Number} pointSize
{"ft_lang_label":"__label__en","ft_lang_prob":0.5527075,"math_prob":0.99032444,"size":3597,"snap":"2022-40-2023-06","text_gpt3_token_len":984,"char_repetition_ratio":0.18090732,"word_repetition_ratio":0.25868726,"special_character_ratio":0.25104254,"punctuation_ratio":0.15505226,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9918661,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-30T12:12:57Z\",\"WARC-Record-ID\":\"<urn:uuid:9611c338-3b90-43fc-a8ca-9ab5e218a984>\",\"Content-Length\":\"50102\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2d8a1915-9ad6-42b7-92eb-9884d18c5dbe>\",\"WARC-Concurrent-To\":\"<urn:uuid:5573302b-7999-4bfd-ba4f-2e228b1b1728>\",\"WARC-IP-Address\":\"50.18.252.155\",\"WARC-Target-URI\":\"https://cocos2d-x.org/reference/html5-js/V2.2.1/symbols/cc.DrawingPrimitiveCanvas.html\",\"WARC-Payload-Digest\":\"sha1:DEF6K3S3G3OTY4QL77SIQSVP73V3AC6L\",\"WARC-Block-Digest\":\"sha1:LK3D4L4XZ7M5LLQ4TI5ZI75WUXZN74NV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764499816.79_warc_CC-MAIN-20230130101912-20230130131912-00716.warc.gz\"}"}