Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### STYLES #
- (info)
- <int> - Integer
- <string> - String
- <color> - #<HHH> or #<HHH> or rgb(<I>, <I>, <I>) or rgba(<I>, <I>, <I>, <float>)
- - where H = [0..F], I = [0..255]
- <size> - <N>px, where N = <int>
- <float> - Float
- font:
- family (<string>|caption|icon|menu|message-box|small-caption|status-bar)
- style: (normal|italic|oblique)
- weight (<int>|normal|bold|bolder|lighter)
- variant (normal|small-caps)
- size (<int>)
- align (start|end|center|left|right)
- valign (alphabetic|top|hanging|middle|ideographic|bottom)
- stroke (<color>)
- color (<color>)
- composite (source-over|source-atop|source-in|source-out|destination-over|
- destination-atop|destination-in|destination-out|lighter|copy|xor)
- opacity (<float[0..1]>)
- line:
- cap (butt|round|square)
- join (bevel|round|miter)
- size (<int>)
- mitter (<int>)
- shadow:
- color (<color>)
- top (<int>)
- left (<int>)
- size (<int>)
- Example:
- ctx.style
- font: {
- family: 'Arial',
- weight: 'bold',
- size: 15,
- align: 'center'
- },
- color: '#fff',
- shadow: {
- color: '#2f0103',
- top: 1
- }
- ###
- CanvasRenderingContext2D::style = (args) ->
- if args.font?
- if args.font.family? || args.font.style? || args.font.weight? || args.font.size? || args.font.variant?
- this.font = (args.font.style || '') + ' ' +
- (args.font.variant || '') + ' ' +
- (args.font.weight || '') + ' ' +
- ((args.font.size|0) + 'px' || '') + ' ' +
- (args.font.family || '')
- this.textAlign = args.font.align || 'left'
- this.textBaseline = args.font.valign || 'top'
- this.strokeStyle = args.stroke || ''
- this.fillStyle = args.color || '#000'
- this.globalCompositeOperation = args.composite || 'source-over'
- this.globalAlpha = args.opacity || 1
- if args.line?
- this.lineCap = args.line.cap || 'butt'
- this.lineJoin = args.line.join || 'miter'
- this.lineWidth = (args.line.size|0) || 1
- this.miterLimit = (args.line.mitter|0) || 10
- if args.shadow?
- this.shadowColor = args.shadow.color if args.shadow.color?
- this.shadowOffsetY = (args.shadow.top|0) || 0
- this.shadowOffsetX = (args.shadow.left|0) || 0
- this.shadowBlur = (args.shadow.size|0) || 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement