Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/decaffeinate files #17

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/creator.coffee → src/coffeeBag/creator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ Namespace('Labeling').Creator = do ->
# store image dimensions in case the user cancels the resize
_lastImgDimensions = {}

# track if the user is "getting started" or well on their way
# track if the user is "get`ting started" or well on their way
_gettingStarted = false

_defaultLabel = '[label title]'

_curvature = 50;

initNewWidget = (widget, baseUrl) ->
$('#image').hide()
$('#chooseimage').show()
Expand Down Expand Up @@ -255,8 +257,8 @@ Namespace('Labeling').Creator = do ->

# drawLine handles the curves and such; run it for inner
# and outer stroke
Labeling.Draw.drawLine(_context, dotx + _offsetX, doty + _offsetY, labelx + _offsetX, labely + _offsetY, 6, '#fff')
Labeling.Draw.drawLine(_context, dotx + _offsetX, doty + _offsetY, labelx + _offsetX, labely + _offsetY, 2, '#000')
Labeling.Draw.drawLine(_context, dotx + _offsetX, doty + _offsetY, labelx + _offsetX, labely + _offsetY, 6, '#fff', _curvature)
Labeling.Draw.drawLine(_context, dotx + _offsetX, doty + _offsetY, labelx + _offsetX, labely + _offsetY, 2, '#000', _curvature)

# Add term to the list, called by the click event
_addTerm = (e) ->
Expand Down
18 changes: 14 additions & 4 deletions src/draw.coffee → src/coffeeBag/draw.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

# Does not import
# import './build/three.js'

Namespace('Labeling').Draw = do ->
# draw a stylized line connecting to a term, with curvature
# shared between player and creator, since it MUST be consistent
# between the two
drawLine: (ctx,x1,y1,x2,y2,width,color) ->
drawLine: (ctx,x1,y1,x2,y2,width,color, curvature) ->
ctx.beginPath()

# move lines
Expand Down Expand Up @@ -33,10 +37,16 @@ Namespace('Labeling').Draw = do ->
lineResultX = -10
lineCurveOffsetX = -60

ctx.lineTo(x2 + labelOffsetX + lineCurveOffsetX, y2 + lineCurveOffsetY)
ctx.lineTo(x2 + labelOffsetX + lineResultX, y2 + labelOffsetY)
# Creates a curve Line
ctx.quadraticCurveTo(
x2 + labelOffsetX + lineCurveOffsetX + curvature,
y2 + lineCurveOffsetY + curvature,
x2 + labelOffsetX + lineResultX,
y2 + labelOffsetY
)


ctx.lineWidth = width
ctx.strokeStyle = color
ctx.lineCap = 'round'
ctx.stroke()

4 changes: 2 additions & 2 deletions src/player.coffee → src/coffeeBag/player.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ Namespace('Labeling').Engine = do ->

# draw a stroked line (one big line, one smaller on top)
_drawStrokedLine = (x1,y1,x2,y2,color1,color2,context = _context) ->
Labeling.Draw.drawLine(context, x1 + _offsetX, y1 + _offsetY, x2 + _offsetX, y2 + _offsetY, 6, color1)
Labeling.Draw.drawLine(context, x1 + _offsetX, y1 + _offsetY, x2 + _offsetX, y2 + _offsetY, 2, color2)
Labeling.Draw.drawLine(context, x1 + _offsetX, y1 + _offsetY, x2 + _offsetX, y2 + _offsetY, 6, color1, 50)
Labeling.Draw.drawLine(context, x1 + _offsetX, y1 + _offsetY, x2 + _offsetX, y2 + _offsetY, 2, color2, 50)

# render the canvas frame
_drawBoard = (mouseX=0,mouseY=0) ->
Expand Down
Loading