Page 1 of 1

Picture positioning

Posted: Tue Mar 03, 2015 9:55 pm
by gheift
Hello there,

I am trying to create a website on which you can edit saved blueprints. But currently I am stucked at displaying the blueprint. I use the information from data/base/prototypes/entity/demo-entities.lua etc. namly entity.selection_box, entitiy.drawing_box, entity.pictures.filename, entity.pictures.width and entity.pictures.height. I already found out that the base unit for the pictures is 32 pixels. But currently the pictures are not shiftet by entity.pictures.shift, because every variation on how to use these values does not result in a correct preview.

Can anybody help me with entity.picture.shift?

To give you an idea of what I am doing: https://ght.io/factorio/blueprint/
In this example especially the accumulators and the radar is misplaced.

Legal Question: Is it allowed to use the graphics and scripts in raw or preprocessed way on a third party website?

Thanks,
Gerhard

(Example copied from https://forums.factorio.com/forum/vie ... 168#p39903)

Re: Picture positioning

Posted: Wed Mar 04, 2015 2:29 am
by rk84
I used paint to aid me.
Left accumulator: Factorio places center of image in center of entity and shift is used to tweak image position.
Right accumulator: This is what I believe to be your case. topleft corners of selectionbox and image in same position.
basic-accumulator.png
basic-accumulator.png (30.64 KiB) Viewed 2394 times
Not sure if this aligns right but. If you replace this

Code: Select all

if false and g.shift then
  gra.style.marginLeft = -g.shift[1] .. 'em'
  gra.style.marginTop =  g.shift[1] .. 'em'
with this

Code: Select all

if g.shift then
  gra.style.marginLeft = g.shift[1] - left - g.width / 64 .. 'em'
  gra.style.marginTop = g.shift[2] - top - g.height / 64 .. 'em'
How does it look?

Re: Picture positioning

Posted: Wed Mar 04, 2015 12:43 pm
by gheift
Thanks, that was the missing information I was not able to find… now I try to import the infos from the factorio data.lua files.

Re: Picture positioning

Posted: Sat Mar 07, 2015 8:41 pm
by Zuzak
This is Awesome.
I copy pasted some of my blueprints into it and seen parts of them graphically outside of game.
When you finish this, Wow.

A suggestion: instead of red squares: have text in a box with entity name as shown in code
eventually, direct base/mod folder access
Possibly by saving the webpage to the Factorio folder and run it from there?

Re: Picture positioning

Posted: Sun Mar 08, 2015 3:00 am
by gheift