Skip to content

Commit

Permalink
Fix preshift handling
Browse files Browse the repository at this point in the history
  • Loading branch information
martenrichter committed Feb 10, 2024
1 parent 26d0fa4 commit d089be9
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ export class DrawObjectPicture extends DrawObject {
commitPreshift(target) {
if (!this.preshift && !this.uncommitted) return
if (target) {
const newstorage = Math.floor(this.posy + (this.preshift.y ?? 0))
const newstorage = Math.floor(this.posy + (this.preshift?.y ?? 0))
if (newstorage !== this.storagenum() || this.uncommitted) {
// ok we have to delete the old obj and create a new one
let newobjid
Expand All @@ -1552,8 +1552,8 @@ export class DrawObjectPicture extends DrawObject {
null,
newobjid,
null,
this.posx + (this.preshift.x ?? 0),
this.posy + (this.preshift.y ?? 0),
this.posx + (this.preshift?.x ?? 0),
this.posy + (this.preshift?.y ?? 0),
this.width,
this.height,
this.uuid
Expand All @@ -1566,8 +1566,8 @@ export class DrawObjectPicture extends DrawObject {
null,
this.objid,
null,
this.posx + (this.preshift.x ?? 0),
this.posy + (this.preshift.y ?? 0)
this.posx + (this.preshift?.x ?? 0),
this.posy + (this.preshift?.y ?? 0)
)
}
}
Expand All @@ -1578,8 +1578,8 @@ export class DrawObjectPicture extends DrawObject {
const newobj = new DrawObjectPicture(target.newobjid(this.objid))
newobj.uncommitted = true
newobj.addPicture(
this.posx + (this.preshift.x ?? 0) + shift.x,
this.posy + (this.preshift.y ?? 0) + shift.y,
this.posx + (this.preshift?.x ?? 0) + shift.x,
this.posy + (this.preshift?.y ?? 0) + shift.y,
this.width,
this.height,
this.uuid,
Expand Down Expand Up @@ -1874,7 +1874,7 @@ export class DrawObjectForm extends DrawObject {
commitPreshift(target) {
if (!this.preshift && !this.uncommitted) return
if (target) {
const newstorage = Math.floor(this.posy + (this.preshift.y ?? 0))
const newstorage = Math.floor(this.posy + (this.preshift?.y ?? 0))
if (newstorage !== this.storagenum() || this.uncommitted) {
// ok we have to delete the old obj and create a new one
let newobjid
Expand All @@ -1888,8 +1888,8 @@ export class DrawObjectForm extends DrawObject {
null,
newobjid,
null,
this.posx + (this.preshift.x ?? 0),
this.posy + (this.preshift.y ?? 0),
this.posx + (this.preshift?.x ?? 0),
this.posy + (this.preshift?.y ?? 0),
this.width,
this.height,
this.formtype,
Expand All @@ -1905,8 +1905,8 @@ export class DrawObjectForm extends DrawObject {
null,
this.objid,
null,
this.posx + (this.preshift.x ?? 0),
this.posy + (this.preshift.y ?? 0)
this.posx + (this.preshift?.x ?? 0),
this.posy + (this.preshift?.y ?? 0)
)
}
}
Expand All @@ -1917,8 +1917,8 @@ export class DrawObjectForm extends DrawObject {
const newobj = new DrawObjectForm(target.newobjid(this.objid))
newobj.uncommitted = true
newobj.addForm(
this.posx + (this.preshift.x ?? 0) + shift.x,
this.posy + (this.preshift.y ?? 0) + shift.y,
this.posx + (this.preshift?.x ?? 0) + shift.x,
this.posy + (this.preshift?.y ?? 0) + shift.y,
this.width,
this.height,
this.formtype,
Expand Down Expand Up @@ -2084,7 +2084,7 @@ export class DrawObjectGlyph extends DrawObject {
if (!this.preshift && !this.uncommitted) return
if (target && this.pathpoints.length > 0) {
const newstorage = Math.floor(
(this.preshift.y ?? 0) + this.pathpoints[0].y * this.isvgscale
(this.preshift?.y ?? 0) + this.pathpoints[0].y * this.isvgscale
)
const oldstorage = this.storagenum()
if (newstorage !== oldstorage || this.uncommitted) {
Expand All @@ -2100,8 +2100,8 @@ export class DrawObjectGlyph extends DrawObject {
null,
newobjid,
null,
this.pathpoints[0].x * this.isvgscale + (this.preshift.x ?? 0),
this.pathpoints[0].y * this.isvgscale + (this.preshift.y ?? 0),
this.pathpoints[0].x * this.isvgscale + (this.preshift?.x ?? 0),
this.pathpoints[0].y * this.isvgscale + (this.preshift?.y ?? 0),
this.gtype,
Color(this.color).rgbNumber(),
this.penwidth * this.isvgscale,
Expand All @@ -2112,8 +2112,8 @@ export class DrawObjectGlyph extends DrawObject {
null,
newobjid,
null,
this.pathpoints[i].x * this.isvgscale + (this.preshift.x ?? 0),
this.pathpoints[i].y * this.isvgscale + (this.preshift.y ?? 0),
this.pathpoints[i].x * this.isvgscale + (this.preshift?.x ?? 0),
this.pathpoints[i].y * this.isvgscale + (this.preshift?.y ?? 0),
this.pathpoints[i].press
)
}
Expand All @@ -2128,8 +2128,8 @@ export class DrawObjectGlyph extends DrawObject {
null,
this.objid,
null,
this.pathpoints[0].x * this.isvgscale + (this.preshift.x ?? 0),
this.pathpoints[0].y * this.isvgscale + (this.preshift.y ?? 0)
this.pathpoints[0].x * this.isvgscale + (this.preshift?.x ?? 0),
this.pathpoints[0].y * this.isvgscale + (this.preshift?.y ?? 0)
)
}
}
Expand All @@ -2140,8 +2140,8 @@ export class DrawObjectGlyph extends DrawObject {
const newobj = new DrawObjectGlyph(target.newobjid(this.objid))
newobj.uncommitted = true
newobj.startPath(
this.pathpoints[0].x * this.isvgscale + (this.preshift.x ?? 0) + shift.x,
this.pathpoints[0].y * this.isvgscale + (this.preshift.y ?? 0) + shift.y,
this.pathpoints[0].x * this.isvgscale + (this.preshift?.x ?? 0) + shift.x,
this.pathpoints[0].y * this.isvgscale + (this.preshift?.y ?? 0) + shift.y,
this.gtype,
Color(
this.color.rgbNumber(),
Expand All @@ -2152,10 +2152,10 @@ export class DrawObjectGlyph extends DrawObject {
for (let i = 1; i < this.pathpoints.length; i++) {
newobj.addToPath(
this.pathpoints[i].x * this.isvgscale +
(this.preshift.x ?? 0) +
(this.preshift?.x ?? 0) +
shift.x,
this.pathpoints[i].y * this.isvgscale +
(this.preshift.y ?? 0) +
(this.preshift?.y ?? 0) +
shift.y,
this.pathpoints[i].press
)
Expand Down

0 comments on commit d089be9

Please sign in to comment.