-
Notifications
You must be signed in to change notification settings - Fork 6
4. Drawing Functions
sean_codes edited this page Jan 6, 2017
·
1 revision
CS Engine has functions for drawing sprites and shapes. You can change settings of the current layer using the set functions.
Sprites:
cs.draw.sprite(sprite, frame, x, y);
cs.draw.spriteExt(img, frame, x, y, angle);
Text:
cs.draw.text(x, y, str);
Note: Limit text usage for better performance. Shapes:
//Rectangle
cs.draw.rect(x, y, width, height, fill[true/false]);
//Line
cs.draw.line(x1, y1, x2, y2);
Set Functions:
//Color
cs.draw.setColor("hexvalue");
//Alpha
cs.draw.setAlpha(0-1);
//Line Thickness
cs.draw.setWidth(decimal);
//Font
cs.draw.setFont('Times New Roman 12px');
//Text Align Horizontal
cs.draw.setTextHort('center, left, right');
//Text Align Vertical
cs.draw.setTextVert('top, bottom, baseline, middle');
//Text Center vertically and hortizontally
cs.draw.setTextCenter();
Note: The set function are reset after any drawing event! They are layer specific and the layer resets after each draw event. You should use these right before your drawing event
//Draw a white filled square
cs.draw.setColor("#FFFFFF");
cs.draw.rect(0, 0, 40, 40, true);