Skip to content

Instantly share code, notes, and snippets.

@isaacw
Forked from RayPS/Framer-Make-CSS-Triangle.coffee
Last active September 26, 2016 21:09
Show Gist options
  • Save isaacw/9f7b6154ce231852afb52bde2ef13801 to your computer and use it in GitHub Desktop.
Save isaacw/9f7b6154ce231852afb52bde2ef13801 to your computer and use it in GitHub Desktop.
Turn layer into a CSS-bassed triangle
# Layer::makeTriangle
# CSS Based triangles
# Directions: "top", "right", "bottom", "left"
# Credit: Black Ray https://gist.github.com/RayPS/9460d020b59fe7a201da65207bb369a0
Layer::makeTriangle = (direction)->
@.borderColor = "transparent"
@.borderWidth = @.width / 2
@.style["border-#{direction}-color"] = @.backgroundColor.toHexString()
@.backgroundColor = "transparent"
# ----------
rect = new Layer
size: 20
backgroundColor: "black"
point: Align.center
rect.makeTriangle "bottom"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment