long story short want draw diagonal grid on calayershape. code instead of straight lines produces kind of curved craziness. looks interesting , wish desired effect, no, it's not.
my questions: 1. how can draw straight lines using cashapelayer? 2. did discover kind of black hole affects gravity of pixels in simulator?
func drawpath(_view:uiview, phase:cgfloat, segment:cgfloat){ // need 2 runs var height = cgrectgetheight(view.frame) let width = cgrectgetwidth(view.frame) let segment:cgfloat = 40 var currentx:cgfloat = segment var cgpath = cgpathcreatemutable() var y = height; y > 0 ; y = y - segment { cgpathmovetopoint(cgpath, nil, 0, y) cgpathaddlinetopoint(cgpath, nil, currentx, 0) cgpathclosesubpath(cgpath) currentx += segment } var layer = cashapelayer() layer.path = cgpath layer.strokecolor = uicolor.redcolor().cgcolor layer.linewidth = 1 layer.fillcolor = uicolor.blackcolor().cgcolor view.layer.addsublayer(layer) } 
what you've drawn straight lines. fact looks curved optical illusion. can same effect yarn , piece of cardboard.
your code doing wrong thing.
you need map out diagonal grid want graph paper, figure out endpoints of diagonal grid, , come loop gives endpoints.
if want draw diagonal grid in 5x5 rectangle you'd draw lines this:
0,1 1,0 0,2 2,0 0,3 3,0 0,4 4,0 your grid spacing more 20 or 30 points every point, , whole grid full size of screen, idea.
Comments
Post a Comment