Giter Site home page Giter Site logo

summer-canvas's Introduction

summer

install

yarn add summer-canvas

example

.html
<canvas id="canvas"></canvas>

.js

import Summer from 'summer-canvas'

const shareCanvas = new Summer({
    ratio: 1,
    canvasId: 'canvas',
    canvasWidth: 343,
    canvasHeight: 'auto',
    radius: 30,
    tasks: [
        {
            type: 'rect',
            id: 'top_cicle_border',
            radius: 80,
            x: 90,
            y: 0,
            width: 162,
            height: 162,
            background: {
                color: 'linear(to s, 0 #fff7be, 100% #f9b71c)'
            }
        }
    ]
})

shareCanvas.draw((img: string, size: { width: string, height: string }) => {

})

method

  1. new Summer(SummerOptions)
  2. draw(doneCallback)
  3. addDraw(ElementOptions)

options

option type description
canvasId string canvas element id
canvasWidth number
canvasHeight 'auto'
tasks (ImgOptions | RectOptions | TextOptions | WrapOptions)[]
ratio? number set in a variety of sizes
border? BorderOptions
background? BackgroundOptions
radius? number
option type description
type 'img'
width number
height? number
img ImgInfoOptions | string
mode? 'contain' | 'cover' | 'fill'
backgroundColor? string
shadow? BoxShadowOptions
border? BorderOptions
option type description
type 'rect'
border? BorderOptions
background? BackgroundOptions
shadow? BoxShadowOptions
option type description
type 'text'
text string
width? number
fontSize? number
lineHeight? number
maxLine? number
lastLineLeastNum? number
color? string
background? BackgroundOptions
radius? number
border? BorderOptions
padding? PaddingOptions
fontWeight? 'normal' | 'lighter' | 'bold' | number
textAlign? 'left' | 'center' | 'right' | 'start' | 'end'
option type description
type 'wrap'
width? number
height? number 'auto'
background? BackgroundOptions
radius? number
padding? number
border? BorderOptions
tasks (ImgOptions | RectOptions | TextOptions | WrapOptions)[]
option type description
id string
hidden? boolean
x? number
y? number
dependOn? DependOnOptions
last? LastTaskOptions
option type description
color? string
image? string
mode? 'fill' | 'cover' | 'contain'
option type description
id string
direction 'cross' | 'vertical'
margin number
option type description
margin number
option type description
left? number
top? number
right? number
bot? number
option type description
img HTMLImageElement
width number
height number
option type description
color? string
offsetX? number
offsetY? number
blur? number
option type description
width number
color string

summer-canvas's People

Contributors

bononwj avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.