on master help sign in
Fix orientation of polygons and paths.
4874949evancz
runtime/Render/Collage.js+4−1
@@ -23,6 +23,7 @@ function trace(ctx, path) {
23
23
24function line(ctx,style,path) {
24function line(ctx,style,path) {
25 style.dashing.ctor === 'Nil' ? trace(ctx, path) : customLineHelp(ctx, style, path);
25 style.dashing.ctor === 'Nil' ? trace(ctx, path) : customLineHelp(ctx, style, path);
26+ ctx.scale(1,-1);
26 ctx.stroke();
27 ctx.stroke();
27}
28}
28
29
@@ -107,6 +108,7 @@ function drawShape(redo, ctx, style, path) {
107 ctx.fillStyle =
108 ctx.fillStyle =
108 sty === 'Solid' ? extract(style._0) :
109 sty === 'Solid' ? extract(style._0) :
109 sty === 'Texture' ? texture(redo, ctx, style._0) : gradient(ctx, style._0);
110 sty === 'Texture' ? texture(redo, ctx, style._0) : gradient(ctx, style._0);
111+ ctx.scale(1,-1);
110 ctx.fill();
112 ctx.fill();
111}
113}
112
114
@@ -126,6 +128,7 @@ function drawImage(redo, ctx, form) {
126 destW = w,
128 destW = w,
127 destH = h;
129 destH = h;
128
130
131+ ctx.scale(1,-1);
129 ctx.drawImage(img, srcX, srcY, srcW, srcH, destX, destY, destW, destH);
132 ctx.drawImage(img, srcX, srcY, srcW, srcH, destX, destY, destW, destH);
130}
133}
131
134
@@ -134,7 +137,7 @@ function renderForm(redo, ctx, form) {
134 var x = form.x, y = form.y, theta = form.theta, scale = form.scale;
137 var x = form.x, y = form.y, theta = form.theta, scale = form.scale;
135 if (x !== 0 || y !== 0) ctx.translate(x, y);
138 if (x !== 0 || y !== 0) ctx.translate(x, y);
136 if (theta !== 0) ctx.rotate(theta);
139 if (theta !== 0) ctx.rotate(theta);
137− ctx.scale(scale,-scale);
140+ if (scale !== 1) ctx.scale(scale,scale);
138 ctx.beginPath();
141 ctx.beginPath();
139 var f = form.form;
142 var f = form.form;
140 switch(f.ctor) {
143 switch(f.ctor) {