-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
211 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
rect -> "rect" _ "=" | ||
_ PositiveIntegerVariable # index | ||
_ "," _ PositiveCssVariable # x1 position | ||
_ "," _ PositiveCssVariable # y1 position | ||
_ "," _ PositiveCssVariable # x2 position | ||
_ "," _ PositiveCssVariable # y2 position | ||
( _ "," _ (PositiveCssValue):? ):? # thickness | ||
( _ "," _ (CssColor):? ):? # line color (optional, defaults to #000) | ||
( _ "," _ (CssColor):? ):? # fill color (optional, defaults to #000) | ||
{% | ||
function(d) { | ||
return { | ||
call: d[0], | ||
index: d[4], | ||
x1: d[8], | ||
y1: d[12], | ||
x2: d[16], | ||
y2: d[20], | ||
thickness: d[21] && d[21][3] ? d[21][3][0] : { val: 1, unit: 'px' }, | ||
lineColor: d[22] && d[22][3] ? d[22][3][0] : '#000', | ||
fillColor: d[23] && d[23][3] ? d[23][3][0] : '#000' | ||
} | ||
} | ||
%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
["border","cardmargins","cardrender","cardside","cardsize","cardsperpage","ellipse","font","image","newcard","pagemargins","pagesize","text","unit"] | ||
["border","cardmargins","cardrender","cardside","cardsize","cardsperpage","ellipse","font","image","newcard","pagemargins","pagesize","rect","text","unit"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
import { Plugin } from '../_base/_plugin'; | ||
|
||
export class Rect extends Plugin { | ||
|
||
static get help() { return 'rect = index, x1, y1, x2, y2 [, borderWidth [, lineColor [, fillColor] ] ]'; } | ||
|
||
static get docs() { return 'The rect directive is used to draw rects on a card. It can also be used to draw simple lines.'; } | ||
|
||
static get examples() { return ['rect = 1, 1, 4, 4, 1px, #aca, #bab']; } | ||
|
||
static get snippets() { | ||
return [` | ||
snippet rect | ||
\rect = \${1:index}, \${2:x1}, \${3:y1}, \${4:x2}, \${5:y2}, \${6:borderWidth}, \${7:lineColor}, \${8:fillColor} | ||
`]; | ||
} | ||
|
||
static operate(args, state, scope) { | ||
super.operate(args, state, scope); | ||
|
||
const { x1, y1, x2, y2, thickness, lineColor, fillColor } = args; | ||
|
||
const left = super.combineForUnit(x1, state); | ||
const top = super.combineForUnit(y1, state); | ||
|
||
const card = state.getCard(args.index); | ||
card.shapes.push({ | ||
shape: 'rect', | ||
left, | ||
top, | ||
width: `calc(${super.combineForUnit(x2, state)} - ${left})`, | ||
height: `calc(${super.combineForUnit(y2, state)} - ${top})`, | ||
'border-width': super.combineForUnit(thickness, state), | ||
'border-color': lineColor, | ||
background: fillColor || 'transparent' | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters