javascript - Drawing a graph using Canvas -
i making graphs using html canvas want draw line multiple colors, @ every point should change new random color,
ctx.moveto(ximg+46,yimg+200); for(i=0;i<num;i++){ if(js_array[i]=="900"){ctx.strokestyle = "grey";} else{ctx.lineto(ximg+50+i*mul,(yimg+200)-(js_array[i]*(height/max)));} }
am gonna change grey random problem colors previous path(line) grey,i want each piece of line in different color,is possible in javascript?
in opengl there command used write take last given color or not,is there similar 1 in javascript?
with context, strokestyle property can take rgba, rgb, , hexadecimal colors name of color.
i suggest along lines of:
ctx.strokestyle = "rgba(" + (math.random()*255) + "," + (math.random()*255) + "," + (math.random()*255) + ", 1)";
or perhaps new function returns color, or assigns it.
if wasn't looking for, supply values undeclared variables can test more thoroughly?
Comments
Post a Comment