UNPKG

dps_canvas

Version:

Html canvas üzerinde şekiller oluşturmanızı sağlar

41 lines (32 loc) 826 B
import Base from "./parent"; export default class Text { static #texts = [] static draw({ x, y, name, color }) { Base.context.beginPath(); Base.context.fillStyle = color || "#fff"; Base.context.font = "15px Arial"; Base.context.textAlign = "center" Base.context.textBaseline = "middle"; Base.context.fillText(name, x, y); Base.context.closePath() } /** * @return {Array} */ static get text() { return Text.#texts } static get lastItem() { return Text.text[Text.text.length - 1] } static add(params) { Text.#texts.push(params) } static deleteTextById(id) { const indexText = Text.#texts.findIndex(t => t.uid === id) Text.#texts.splice(indexText, 1) } static clearItem() { Text.#texts = [] } }